Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 29
Default Leading zero in hyperlink TextToDisplay

Hello

I have a macro that allows the user to insert a hyperlink to a pdf
file. The macro allows them to browse to a pdf file, click on it and
the link will be inserted. This seemed to be working fine until Excel
2003.

The pdf files are numbered, and may have leading zeroes (names are all
seven characters long).

Following are some fragments of my macro:

Sub CreateHyperlink()
Dim FName As String, DispName As String
'
Code to extract filename from full path and remove .pdf
'
'
' Create the hyperlink
'
ActiveSheet.Hyperlinks.Add Anchor:=ActiveCell, _
Address:=FName, TextToDisplay:=DispName
End Sub

If I "watch" the DispName variable, the code works correctly and it has
a seven digit value (such as 0654321). However, when inserted in the
spreadsheet the hyperlink drops the leading zero and displays 654321.
I've tried various formatting options. If I (via the macro) put an
apostrophe in front of DispName it shows up correctly (eg
TextToDisplay:="'" & DispName), but then the XL2003 error checking
kicks in and I get little green triangles everywhere.

Can anyone suggest what might have changed between 2000 and 2003, and
more importantly how I can prevent it from dropping the leading zeroes?

Thanks

Murray

  #2   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 4,391
Default Leading zero in hyperlink TextToDisplay

Murray,
What if you use the HYPERLINK WS formula instead:

ActiveCell.FormulaR1C1 = "=HYPERLINK(""C:\Hlink.xls"",""006542"")"

NickHK

"Murray" wrote in message
ups.com...
Hello

I have a macro that allows the user to insert a hyperlink to a pdf
file. The macro allows them to browse to a pdf file, click on it and
the link will be inserted. This seemed to be working fine until Excel
2003.

The pdf files are numbered, and may have leading zeroes (names are all
seven characters long).

Following are some fragments of my macro:

Sub CreateHyperlink()
Dim FName As String, DispName As String
'
Code to extract filename from full path and remove .pdf
'
'
' Create the hyperlink
'
ActiveSheet.Hyperlinks.Add Anchor:=ActiveCell, _
Address:=FName, TextToDisplay:=DispName
End Sub

If I "watch" the DispName variable, the code works correctly and it has
a seven digit value (such as 0654321). However, when inserted in the
spreadsheet the hyperlink drops the leading zero and displays 654321.
I've tried various formatting options. If I (via the macro) put an
apostrophe in front of DispName it shows up correctly (eg
TextToDisplay:="'" & DispName), but then the XL2003 error checking
kicks in and I get little green triangles everywhere.

Can anyone suggest what might have changed between 2000 and 2003, and
more importantly how I can prevent it from dropping the leading zeroes?

Thanks

Murray



  #3   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 29
Default Leading zero in hyperlink TextToDisplay

NIckHK

Thanks for the suggestion. I tried that, and got it working. However,
this is in a server environment and using "HYPERLINK" seemed to use
drive letters rather than the full URL (eg W:\ rather than
\\servername). I didn't want to be dependent on a users drive mapping
which I can't necessarily control.

Perhaps I have gotten something wrong with my HYPERLINK code? It was
basically the same - I even inserted the same variables of Fname and
DispName after I had derived them.

Regards

Murray

NickHK wrote:
Murray,
What if you use the HYPERLINK WS formula instead:

ActiveCell.FormulaR1C1 = "=HYPERLINK(""C:\Hlink.xls"",""006542"")"

NickHK

"Murray" wrote in message
ups.com...
Hello

I have a macro that allows the user to insert a hyperlink to a pdf
file. The macro allows them to browse to a pdf file, click on it and
the link will be inserted. This seemed to be working fine until Excel
2003.

The pdf files are numbered, and may have leading zeroes (names are all
seven characters long).

Following are some fragments of my macro:

Sub CreateHyperlink()
Dim FName As String, DispName As String
'
Code to extract filename from full path and remove .pdf
'
'
' Create the hyperlink
'
ActiveSheet.Hyperlinks.Add Anchor:=ActiveCell, _
Address:=FName, TextToDisplay:=DispName
End Sub

If I "watch" the DispName variable, the code works correctly and it has
a seven digit value (such as 0654321). However, when inserted in the
spreadsheet the hyperlink drops the leading zero and displays 654321.
I've tried various formatting options. If I (via the macro) put an
apostrophe in front of DispName it shows up correctly (eg
TextToDisplay:="'" & DispName), but then the XL2003 error checking
kicks in and I get little green triangles everywhere.

Can anyone suggest what might have changed between 2000 and 2003, and
more importantly how I can prevent it from dropping the leading zeroes?

Thanks

Murray


  #4   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 4,391
Default Leading zero in hyperlink TextToDisplay

Murray,
I'm not curently connected to a server, so I can't test, but according to
Help:
<Excel Help
"In Excel for Windows, the following example displays the contents of cell
D5 as the jump text in the cell and opens the file named 1stqtr.xls, which
is stored on the server named FINANCE in the Statements share. This example
uses a UNC path:
=HYPERLINK("\\FINANCE\Statements\1stqtr.xls", D5)
</Excel Help

You mean this then gets resolved and altered to the mapped drive path
instead of the UNC path ?

NickHK

"Murray" wrote in message
oups.com...
NIckHK

Thanks for the suggestion. I tried that, and got it working. However,
this is in a server environment and using "HYPERLINK" seemed to use
drive letters rather than the full URL (eg W:\ rather than
\\servername). I didn't want to be dependent on a users drive mapping
which I can't necessarily control.

Perhaps I have gotten something wrong with my HYPERLINK code? It was
basically the same - I even inserted the same variables of Fname and
DispName after I had derived them.

Regards

Murray

NickHK wrote:
Murray,
What if you use the HYPERLINK WS formula instead:

ActiveCell.FormulaR1C1 = "=HYPERLINK(""C:\Hlink.xls"",""006542"")"

NickHK

"Murray" wrote in message
ups.com...
Hello

I have a macro that allows the user to insert a hyperlink to a pdf
file. The macro allows them to browse to a pdf file, click on it and
the link will be inserted. This seemed to be working fine until Excel
2003.

The pdf files are numbered, and may have leading zeroes (names are all
seven characters long).

Following are some fragments of my macro:

Sub CreateHyperlink()
Dim FName As String, DispName As String
'
Code to extract filename from full path and remove .pdf
'
'
' Create the hyperlink
'
ActiveSheet.Hyperlinks.Add Anchor:=ActiveCell, _
Address:=FName, TextToDisplay:=DispName
End Sub

If I "watch" the DispName variable, the code works correctly and it

has
a seven digit value (such as 0654321). However, when inserted in the
spreadsheet the hyperlink drops the leading zero and displays 654321.
I've tried various formatting options. If I (via the macro) put an
apostrophe in front of DispName it shows up correctly (eg
TextToDisplay:="'" & DispName), but then the XL2003 error checking
kicks in and I get little green triangles everywhere.

Can anyone suggest what might have changed between 2000 and 2003, and
more importantly how I can prevent it from dropping the leading

zeroes?

Thanks

Murray




  #5   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 29
Default Leading zero in hyperlink TextToDisplay

Brilliant!

As it turns out, my path variable contained the mapped drive path, and
the ActiveSheet.Hyperlinks command resolved it to a full UNC path,
rather than the other way around. I changed the code to pass the UNC
path to GetOpenFilename (courtesy of some code posted by Bob Phillips)
and now the =HYPERLINK() contains the UNC path and works fine.

Why the original code ceased to put the leading zeroes remains a
mystery. If anyone has an answer I'd be interested to know.

Thanks NickHK for your help

Regards

Murray

NickHK wrote:
Murray,
I'm not curently connected to a server, so I can't test, but according to
Help:
<Excel Help
"In Excel for Windows, the following example displays the contents of cell
D5 as the jump text in the cell and opens the file named 1stqtr.xls, which
is stored on the server named FINANCE in the Statements share. This example
uses a UNC path:
=HYPERLINK("\\FINANCE\Statements\1stqtr.xls", D5)
</Excel Help

You mean this then gets resolved and altered to the mapped drive path
instead of the UNC path ?

NickHK

"Murray" wrote in message
oups.com...
NIckHK

Thanks for the suggestion. I tried that, and got it working. However,
this is in a server environment and using "HYPERLINK" seemed to use
drive letters rather than the full URL (eg W:\ rather than
\\servername). I didn't want to be dependent on a users drive mapping
which I can't necessarily control.

Perhaps I have gotten something wrong with my HYPERLINK code? It was
basically the same - I even inserted the same variables of Fname and
DispName after I had derived them.

Regards

Murray

NickHK wrote:
Murray,
What if you use the HYPERLINK WS formula instead:

ActiveCell.FormulaR1C1 = "=HYPERLINK(""C:\Hlink.xls"",""006542"")"

NickHK

"Murray" wrote in message
ups.com...
Hello

I have a macro that allows the user to insert a hyperlink to a pdf
file. The macro allows them to browse to a pdf file, click on it and
the link will be inserted. This seemed to be working fine until Excel
2003.

The pdf files are numbered, and may have leading zeroes (names are all
seven characters long).

Following are some fragments of my macro:

Sub CreateHyperlink()
Dim FName As String, DispName As String
'
Code to extract filename from full path and remove .pdf
'
'
' Create the hyperlink
'
ActiveSheet.Hyperlinks.Add Anchor:=ActiveCell, _
Address:=FName, TextToDisplay:=DispName
End Sub

If I "watch" the DispName variable, the code works correctly and it

has
a seven digit value (such as 0654321). However, when inserted in the
spreadsheet the hyperlink drops the leading zero and displays 654321.
I've tried various formatting options. If I (via the macro) put an
apostrophe in front of DispName it shows up correctly (eg
TextToDisplay:="'" & DispName), but then the XL2003 error checking
kicks in and I get little green triangles everywhere.

Can anyone suggest what might have changed between 2000 and 2003, and
more importantly how I can prevent it from dropping the leading

zeroes?

Thanks

Murray



Reply
Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules

Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On


Similar Threads
Thread Thread Starter Forum Replies Last Post
Intra-workbook hyperlink: macro/function to return to hyperlink ce marika1981 Excel Discussion (Misc queries) 3 May 6th 05 05:47 AM
Macro to Copy Hyperlink to another file as a HYPERLINK, not text... dollardoc Excel Programming 1 April 7th 05 12:47 AM
How can I pass an array as TextToDisplay to a hyperlink? Jay Fincannon Excel Programming 4 January 28th 05 01:45 AM
Hyperlink TexttoDisplay James[_32_] Excel Programming 5 September 27th 04 01:59 PM
reading html when hyperlink address not hyperlink text diplayed Kevin Excel Programming 1 December 4th 03 10:13 PM


All times are GMT +1. The time now is 09:28 PM.

Powered by vBulletin® Copyright ©2000 - 2025, Jelsoft Enterprises Ltd.
Copyright ©2004-2025 ExcelBanter.
The comments are property of their posters.
 

About Us

"It's about Microsoft Excel"