2/28/2006

Create a Hyperlink in Excel Spreadsheet Using VBScript

Someone at the newsgroup asked this question. This is the VBScript that I wrote to accomplish this.


Dim objExcel
Set objExcel = WScript.CreateObject("Excel.Application")

objExcel.Visible = TRUE
objExcel.Workbooks.Open "C:\bin\test.xls"
objExcel.Workbooks(1).Activate
objExcel.Workbooks(1).Worksheets(1).Range("A1").Select

Dim sLinkAddress
sLinkAddress = "http://www.google.com"

objExcel.Workbooks(1).Worksheets(1).Hyperlinks.Add _
objExcel.Selection, sLinkAddress
objExcel.Workbooks(1).SaveAs "C:\bin\test.xls"
objExcel.Quit

set objExcel = nothing

0 Comments:

Post a Comment

<< Home