Hyperlink Excel2000 vs Excel2002

G

Guest

The following code is used in an Excel Macro and when ran in Excel2000
creates a valid hyperlink but in Excel2002 it does not.

ActiveSheet.Hyperlinks.Add Anchor:=Selection, Address:= _
"\\S10AC52B\Eng\SCN\" & SCNFile, TextToDisplay:= _
"" & SCNNumber

When SCNFile is set equal to "3PH-04011.xls" the hyperlink url that's
created in Excel2000 looks like " \\S10AC52B\Eng\SCN\3PH-04011.xls" but when
created in Excel2002 it looks like "..\..\Eng\SCN\3PH-04011.xls"

Anyone have an idea as to why excel would change the url? How can I make it
work correctly?
 
T

Tim Williams

Have you tried creating the hyperlink by inserting a "=HYPERLINK(...)"
formula into the cell ?

sURL = "\\S10AC52B\Eng\SCN\" & SCNFile
sText = SCNNumber
selection.formula = "=HYPERLINK(" & sURL & "," & sText & ")"

Tim.
 
G

Guest

Tim,

Tried this and I get a "Application or User defined error" thrown at me when
it hits the Selection.Formula line

Looking at what this looks like when done manually:
=HYPERLINK("\\s10ac52b\eng\scn\3ph-0412","3PH-0413")
I may have to place some quote marks into it.
 
G

Guest

Changing this to
selection.formula = "=HYPERLINK(""" & sURL & """,""" & sText & """)"
allows this formula to be inserted and it at least works on my Excel2000.
Will be trying it soon on a Excel2002 version.
 
T

Tim Williams

Yep - always happens when I don't test before posting..

Good luck with the 2002..

Tim
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top