Replace part of hyperlink

后端 未结 2 507
粉色の甜心
粉色の甜心 2021-01-14 17:42

I need to modify a lot of hyperlinks in an .xls workbook. My links are like this:

\\\\\\mysrv001\\some\\path\\documents.doc and I need to replace

2条回答
  •  轮回少年
    2021-01-14 18:08

    Whoops! You're extracting and keeping the left part of your path string, where what you really want to do is to discard it!

    EDIT: Also, you can't use string functions (Left, Right, Len...) on a Hyperlink object like that. This is what is causing the error. You have to extract the Hyperlink object's Address property -- that's a string.

    Replace

    path = Left(hLink, 11) ' throws error: Object doesn't support this property...
    

    with

    path = Mid(hLink.Address, 12) ' returns "some\path\documents.doc"
    ' or, equivalently:
    'path = Right(hLink.Address, Len(hLink.Address) - 11) 
    

提交回复
热议问题