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:ReportsFile 154867452 of 154867500 files.pdf
chage to: ReportsFile%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:ReportsFile 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)
question from:
https://stackoverflow.com/questions/65891413/excel-cell-hyperlink-automatically-change-from-path-to-url 与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…