Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations strongm on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

run time error when creating hyperlink

Status
Not open for further replies.

saltir

Programmer
Oct 14, 2009
13
MT
Hi,

I am relative new to this and would appreciate it a lot if someone helped me out with this code. I have a db which opens an excel sheet.
In one of the cells I would like to insert a hyperlink to another excel sheet.
However I am getting the below error.
Run - time error2147467259 (80004005)
Automation error
Unspecified error


Below is the code I am using


Set appexcel = CreateObject("Excel.Application")
Set wbexcel = appexcel.Workbooks.Open("C:\Documents and Settings\saltir\Desktop\workorder_log.xls")

Set asheet = wbexcel.Sheets("Sheet1")
appexcel.Visible = True


With asheet
.Range("B2").Select
.Hyperlinks.Add Anchor:=Selection, Address:="C:\documents\leave.xls", TextToDisplay:="Leave"
End With


Any help would be greatly appreciated as I've been going around in circles for quite some time now .


Thanks
 
First, which line of code raises the error ?
My guess:
With asheet
.Hyperlinks.Add Anchor:=.Range("B2"), Address:="C:\documents\leave.xls", TextToDisplay:="Leave"
End With


Hope This Helps, PH.
FAQ219-2884
FAQ181-2886
 
my guess is
Address:="C:\documents\leave.xls

needs to be changed to "file://C:\documents\leave.xls
 
Hi ,

Yes , you are right it is the below statement which raises the error (apologies for not pointing that out).

.Hyperlinks.Add Anchor:=.Range("B2"), Address:="C:\documents\leave.xls", TextToDisplay:="Leave"

I have tried to change the addrss as vbajock suggested but to no avail.


Any other suggestions would be more then welcome.


 
Hi,

I just missed that and it worked....Thanks a lot
I really appreciate your help :)

 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top