Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 33
Default Hyperlink written to worksheet produces error

John,
I think that the Address parameter refers to a file address. Try SubAddress
as a range or named range in the same workbook.

AlexJ


"John Wirt" wrote in message
...
I'm writing a subroutine to list all the worksheets in a
workbook on a new worksheet called, "List of Worksheets."

Here is the code:

For Each Wsh In Sheets
strWshName = Wsh.Name
If strWshName < "List of Worksheets" Then
I = I + 1
Set RA = Range(Replace("B" & Str(I), " ", ""))
RA.FormulaR1C1 = strWshName
strAddress = Replace("'" & strWshName & "'!
A1", " ", "")
Wsh.Hyperlinks.Add _
Anchor:=RA, _
Address:=strAddress, _
TextToDisplay:=strWshName
End If
Next Wsh

Teh problem is that when I click on the inserted links I
get an error message: "Cannot open the specified file."

Indeed, if I try to edit the hyperlink directly, the
correct sheet address (e.g. 'Sheet2'!A1) is in the address
field of the Edit Hyperlinks window but the "Link to"
selection is "Existing File or web Page" rather
than "Place in this document." How do I write the
Hyperink.Add statement specify that the hyperlink is for a
__place in the document__ and not a web address or a
filename?

Thanks.

John Wirt



  #2   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 1
Default Hyperlink written to worksheet produces error

I'm writing a subroutine to list all the worksheets in a
workbook on a new worksheet called, "List of Worksheets."

Here is the code:

For Each Wsh In Sheets
strWshName = Wsh.Name
If strWshName < "List of Worksheets" Then
I = I + 1
Set RA = Range(Replace("B" & Str(I), " ", ""))
RA.FormulaR1C1 = strWshName
strAddress = Replace("'" & strWshName & "'!
A1", " ", "")
Wsh.Hyperlinks.Add _
Anchor:=RA, _
Address:=strAddress, _
TextToDisplay:=strWshName
End If
Next Wsh

Teh problem is that when I click on the inserted links I
get an error message: "Cannot open the specified file."

Indeed, if I try to edit the hyperlink directly, the
correct sheet address (e.g. 'Sheet2'!A1) is in the address
field of the Edit Hyperlinks window but the "Link to"
selection is "Existing File or web Page" rather
than "Place in this document." How do I write the
Hyperink.Add statement specify that the hyperlink is for a
__place in the document__ and not a web address or a
filename?

Thanks.

John Wirt
  #3   Report Post  
Posted to microsoft.public.excel.programming
No Name
 
Posts: n/a
Default Hyperlink written to worksheet produces error

Alex,

Thank you. Adding the sheet and cell location as a
SubAddress works. The VB Help is not very clear on this. I
found that the sheet name should be entered without
quotes, and the Address must be entered as a blank.
Otherwise, the Hyplinks.Add statement fails.

For Each Wsh In Sheets
strWshName = Wsh.Name
If strWshName < "List of Worksheets" Then
I = I + 1
Set RA = Range(Replace("B" & Str(I), " ", ""))
'RA.FormulaR1C1 = strWshName
strAddress = Replace(strWshName & "!A1", " ", "")
ActiveSheet.Hyperlinks.Add _
Anchor:=RA, _
Address:="", _
SubAddress:=strAddress, _
TextToDisplay:=strWshName
End If
Next Wsh

John Wirt
-----Original Message-----
John,
I think that the Address parameter refers to a file

address. Try SubAddress
as a range or named range in the same workbook.

AlexJ


"John Wirt" wrote

in message
...
I'm writing a subroutine to list all the worksheets in a
workbook on a new worksheet called, "List of

Worksheets."

Here is the code:

For Each Wsh In Sheets
strWshName = Wsh.Name
If strWshName < "List of Worksheets" Then
I = I + 1
Set RA = Range(Replace("B" & Str(I), " ", ""))
RA.FormulaR1C1 = strWshName
strAddress = Replace("'" & strWshName & "'!
A1", " ", "")
Wsh.Hyperlinks.Add _
Anchor:=RA, _
Address:=strAddress, _
TextToDisplay:=strWshName
End If
Next Wsh

Teh problem is that when I click on the inserted links I
get an error message: "Cannot open the specified file."

Indeed, if I try to edit the hyperlink directly, the
correct sheet address (e.g. 'Sheet2'!A1) is in the

address
field of the Edit Hyperlinks window but the "Link to"
selection is "Existing File or web Page" rather
than "Place in this document." How do I write the
Hyperink.Add statement specify that the hyperlink is

for a
__place in the document__ and not a web address or a
filename?

Thanks.

John Wirt



.

  #4   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 8
Default Hyperlink written to worksheet produces error

Well, no, the quotes are needed if the sheet name has a
blank in it. Of course.

strAddress = Replace(""" & strWshName & "'!

A1", " ", "")

-----Original Message-----
Alex,

Thank you. Adding the sheet and cell location as a
SubAddress works. The VB Help is not very clear on this.

I
found that the sheet name should be entered without
quotes, and the Address must be entered as a blank.
Otherwise, the Hyplinks.Add statement fails.

For Each Wsh In Sheets
strWshName = Wsh.Name
If strWshName < "List of Worksheets" Then
I = I + 1
Set RA = Range(Replace("B" & Str(I), " ", ""))
'RA.FormulaR1C1 = strWshName
strAddress = Replace(strWshName & "!A1", " ", "")
ActiveSheet.Hyperlinks.Add _
Anchor:=RA, _
Address:="", _
SubAddress:=strAddress, _
TextToDisplay:=strWshName
End If
Next Wsh

John Wirt
-----Original Message-----
John,
I think that the Address parameter refers to a file

address. Try SubAddress
as a range or named range in the same workbook.

AlexJ


"John Wirt" wrote

in message
...
I'm writing a subroutine to list all the worksheets in

a
workbook on a new worksheet called, "List of

Worksheets."

Here is the code:

For Each Wsh In Sheets
strWshName = Wsh.Name
If strWshName < "List of Worksheets" Then
I = I + 1
Set RA = Range(Replace("B" & Str(I), " ", ""))
RA.FormulaR1C1 = strWshName
strAddress = Replace("'" & strWshName & "'!
A1", " ", "")
Wsh.Hyperlinks.Add _
Anchor:=RA, _
Address:=strAddress, _
TextToDisplay:=strWshName
End If
Next Wsh

Teh problem is that when I click on the inserted links

I
get an error message: "Cannot open the specified

file."

Indeed, if I try to edit the hyperlink directly, the
correct sheet address (e.g. 'Sheet2'!A1) is in the

address
field of the Edit Hyperlinks window but the "Link to"
selection is "Existing File or web Page" rather
than "Place in this document." How do I write the
Hyperink.Add statement specify that the hyperlink is

for a
__place in the document__ and not a web address or a
filename?

Thanks.

John Wirt



.

.

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
Error on large Excel spreadsheet with VBA, written in '03 used inmixed '03 - '07 environment [email protected] Excel Discussion (Misc queries) 0 January 10th 08 06:05 AM
Excel 2002 produces error in calculation. Wes at CCC Excel Discussion (Misc queries) 4 November 16th 07 08:54 PM
Refresh produces #N/A error RhysPieces Links and Linking in Excel 1 July 11th 07 07:42 PM
Refresh produces #N?A error RhysPieces Excel Discussion (Misc queries) 1 July 10th 07 09:16 AM
CreateObject produces error Robert Chapman Excel Programming 0 August 15th 03 03:48 PM


All times are GMT +1. The time now is 12:04 PM.

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

About Us

"It's about Microsoft Excel"