Categories: MSDN / DotNet / Java / Scripts / Linux / PHP Ask - La ask - La Answer

VBscript adding hyperlink to excel

Hi I am having issues using a VBscript to add hyperlinks to excel spreadsheet

The part of the code that is causing the issue is highlighted in bold:

Do Until objRecordSet.EOF

On Error resume next
If InStr(LCase(objRecordSet.Fields("OperatingSystem").Value),"server") Then

ObjXL.ActiveSheet.Cells(icount,1).Value = objRecordSet.Fields("Name").Value
ObjXL.ActiveSheet.Cells(icount,2).Value = objRecordSet.Fields("Location").Value
ObjXL.ActiveSheet.Cells(icount,3).Value = objRecordSet.Fields("OperatingSystem").Value
ObjXL.ActiveSheet.Cells(icount,4).Value = objRecordSet.Fields("operatingSystemServicePack").Value
ObjXL.Sheets.Add
ObjXL.ActiveSheet.Name =objRecordSet.Fields("Name").Value
ObjXL.Sheets("Sheet1").Select
objxl.activesheet.Hyperlinks.Add Anchor:= selection ObjXL.ActiveSheet.Cells("A1").select ,SubAddress:="sheet1!A1"
icount = icount + 1

End If

When I run this script it errors saying

Line 61
Char 42
error Expected statement
code 800A0400
source Miscrosoft VBScript Compilation error

Any help would be great
[1206 byte] By [mattlucas] at [2007-11-11 7:20:01]
# 1 Re: VBscript adding hyperlink to excel
The Add method of the Hyperlinks collection is defined as follows:

Function Add(Anchor As Object, Address As String, [SubAddress], [ScreenTip], [TextToDisplay]) As Object

What are you trying to do with "objXL.ActiveSheet.Cells("A1").Select"?
Phil Weber at 2007-11-11 17:27:12 >