ExcelBanter

ExcelBanter (https://www.excelbanter.com/)
-   Excel Programming (https://www.excelbanter.com/excel-programming/)
-   -   How to lookup hyperlinked cells (https://www.excelbanter.com/excel-programming/296237-how-lookup-hyperlinked-cells.html)

neil kempinski

How to lookup hyperlinked cells
 
I want to hyperlink several cells to pdf files. Then want to use
lookup function to return a cell and then print both the current wor
sheet and the hyperlinked pdf file.

Can this be done?

thanks
nei

--
Message posted from http://www.ExcelForum.com


Bill Renaud[_2_]

How to lookup hyperlinked cells
 
Your solution would have to include a UDF (user-defined function) to return
the hyperlink address contained in the cell that has a hyperlink in it. Try
the function below (I have been working on a more sophisticated version for
the Else portion of the clause that will return the URL if the Link argument
is a cell with a HYPERLINK function, but I don't have it fully debugged in
the case of a nested function, etc.).

Public Function HyperlinkURL(Link As Range) As Variant
With Link
If .Hyperlinks.Count 0 _
Then
'Return the URL of the hyperlink.
HyperlinkURL = .Hyperlinks(1).Address
Else
'Return #N/A! error value if none found.
HyperlinkURL = CVErr(xlErrNA)
End If
End With
End Function

After printing the current worksheet, you would then have to use the Shell
statement to execute a command line similar to the following
"C:\Program Files\Adobe\Acrobat 5.0\Reader\AcroRd32.exe" /p /h "%1" to print
out the PDF file, where "%1" would be replaced by the hyperlink address
returned by the function above.

I am assuming that you have a command button that you want to click to print
out the current worksheet, then fetch the address of the PDF document at the
active cell, then print that out. Technically, you can't do that with a
function. A function can only return a value to a cell, not perform actions
that would be carried out by a command macro.
--
Regards,
Bill


"neil kempinski " wrote in
message ...
I want to hyperlink several cells to pdf files. Then want to use a
lookup function to return a cell and then print both the current work
sheet and the hyperlinked pdf file.

Can this be done?

thanks
neil


---
Message posted from http://www.ExcelForum.com/





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

Powered by vBulletin® Copyright ©2000 - 2025, Jelsoft Enterprises Ltd.
ExcelBanter.com