Hi David,
Two things. First,
HyperlinkPart([Hyper], 0)
returns the DisplayedValue of the link in Access, which is not
necessarily the same as the address. Try
HyperlinkPart([Hyper], 5)
instead: this returns the full address (including a subaddress such as a
bookmark if there is one).
Next, it's so long since I've done this that I forgot that all that gets
you is the URLs as text in Excel cells. It's also necessary to persuade
Excel that they're hyperlinks.
One way to do this is to have the URLs in one column, and use the
HYPERLINK() worksheet function in another column. E.g. if there's a URL
in cell B3, putting =HYPERLINK(B3) in another cell gives you a clickable
hyperlink.
Or you can use a bit of VBA code to turn the URLs into real Excel
hyperlinks. This shows the basic idea:
Sub ConvertURLToHyperLinkDemo()
Dim C As Excel.Range
With Application
For Each C In .Selection.Cells
ActiveSheet.Hyperlinks.Add C, C.Text
Next C
End With
End Sub
Hi John,
Thank you for your help. I didn't know about the HperlinkPart() function so
I am learning something new today.
I am exporting from a query. Based on your suggestion I changed the
hyperlink to incorporate the new function as: HyperlinkPart([Hyper],0) where
"Hyper" is the field name for the hyperlink in the Access table. After
export to Excel, the hyperlinks in the spreadsheet look like hyperlinks and
no longer have the leading and trailing #. However, they still don't do
anything when I click them. Am I still doing something wrong? Is there a
way to export a hyperlink from Access to Excel that retains the full
hyperlink functionality in Excel?
Thanks again,
David
John Nurick said:
Hi David,
I think the simplest approach is to use the HyperlinkPart() function in your
query, to extract the URL from the hyperlink field.
Alternatively you can export the field value complete with the #s (whose
meaning is explained in the Help for HyperlinkPart) and then use a formula in
Excel to extract the URL. The Excel HYPERLINK() function turns a URL into a
hyperlink.
--
John Nurick
Microsoft Access MVP
:
I am exporting records from Access to Excel. One of the fields is a
hyperlink and I am having trouble getting a working link by the time it
reaches Excel. What techniques are needed to make this work?
One thing that I noticed is that the hyperlink in Excel has leading and
trailing pound symbols (#) that weren't there in Access. If I remove the #
then the hyperlink works. Is a possible solution to prevent # from being
added? If so, how do I do that?
Thanks,
David