I have this procedure to add an (absolute) link to a cell. VBA creates the link fine but Excel automatically changes the previous link to an URL link.
Sub SetHyperlink(ByVal wsSheets_I As Worksheets, ByVal sPDFFile_I As String, ByVal lRowMd_I As Long)
ActiveSheet.Hyperlinks.Add _
Anchor:=wsSheets_I.Range("A" & lRowMd_I), _
Address:=sPDFFile_I, _
TextToDisplay:=wsSheets_I.Cells("C" & lRowMd_I).Value
End Sub
For example: D:\Reports\File 154867452 of 154867500 files.pdf
chage to: Reports\File%20154867452%20of%20154867500%20files.pdf
if I select "Modify hyperlink" in Excel context menu
Then Debug.Print (wsSheets_I.Range("A" & lRowMd_I).Hyperlinks(1).Address)
returns Reports/File 154867452 of 154867500 files.pdf
(changing "\"
to "/"
) but the link works correctly in Excel.
How can I do that Debug.Print (wsSheets_I.Range("A" & lRowMd_I).Hyperlinks(1).Address)
return the original D:\Reports\File 154867452 of 154867500 files.pdf
I don't care about the relative or absolute path (Hyperlink Base property)
Excel 365 MSO (16.0.135302)32 bits, Windows 10 (64 bits)
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.