LinkBack Thread Tools Search this Thread Display Modes
Prev Previous Post   Next Post Next
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 553
Default Hyperlink Code only works when file saved on desktop

Effectively teh code loops though sheets then cells and finds information.
It then prints the cell address of the cell that has the the information its
looking for on a summary sheet within the same file.

The variable rng is where it creates/pastes the hyperlink. Variables a and
b are what are used for the hyperlink information. This is nothing more than
cell address and file path information from the cell in question.

This only works when the file that its searching is saved on my desktop. If
I save the file anywhere else, the hyperlink gets created with the correct
cell adderss as text. But when you click on it, it creates an error saying
"Reference is not valid". When I right click on the hyperlink and go to Edit
Hyperlinks the problem seems to be that the Cell Reference. When clicked
upon it says A1 (which is nto the value I passed to it in the code - E2) and
the wrong source sheet is highlighted in the shee director tree. If I simply
click OK, the hyperlink then starts to work albeit with the wrong Cell
Reference.

Now this is odd because when I run the code and watch the immediate window I
get the exact same result whether the file is saved on my Desktop or My
Documents. But when the code is finished, the data for variables a and b
show up differently in the actual hyperlink itself.

Saved to My Document
?a
Colour Legend!E2
?b
'C:\Documents and Settings\Me\My Documents\Excel Documents\[Test
File.xls]Colour Legend'!E2

Saved to Desktop
?a
Colour Legend!E2
?b
'C:\Documents and Settings\Me\Desktop\[Test File.xls]Colour Legend'!E2


Private Sub CellAddressPass(a As String, b As String, rng As Range)
a = Cell.Parent.Name & "!" & _
Cell.Address(0, 0)

b = "'" & Workbooks(OriginalWorkbook).Path & "\[" &
Workbooks(OriginalWorkbook).Name & "]" & Cell.Parent.Name & "'!" & _
Cell.Address(0, 0)

'Pass variable values to Hyperlink Creation
rng.Parent.Hyperlinks.Add Anchor:=rng, Address:="", _
SubAddress:=b, _
TextToDisplay:=a

End Sub

Any thoughts - Thanks
 
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
formula only works when file is saved. bob New Users to Excel 1 August 2nd 09 05:50 AM
why does excel create a new desktop icon when file is saved? PLEES Setting up and Configuration of Excel 0 August 3rd 08 10:24 PM
EXCEL FILES SAVED TO DESKTOP WILL NOT OPEN FROM DESKTOP randy111 Excel Discussion (Misc queries) 3 January 13th 08 10:38 PM
why is absolute hyperlink in XLS file changed when file is saved SusanJ Excel Discussion (Misc queries) 3 August 17th 07 02:24 AM
VB Code Works Perfect...but Not when the File is Shared TEAM[_4_] Excel Programming 3 September 15th 05 04:55 PM


All times are GMT +1. The time now is 04:27 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"