Thread: [Solved] Batch Hyperlinking files
View Single Post
 
Old 04-20-2020, 02:27 PM
macropod's Avatar
macropod macropod is offline Windows 7 64bit Office 2010 32bit
Administrator
 
Join Date: Dec 2010
Location: Canberra, Australia
Posts: 22,359
macropod has a reputation beyond reputemacropod has a reputation beyond reputemacropod has a reputation beyond reputemacropod has a reputation beyond reputemacropod has a reputation beyond reputemacropod has a reputation beyond reputemacropod has a reputation beyond reputemacropod has a reputation beyond reputemacropod has a reputation beyond reputemacropod has a reputation beyond reputemacropod has a reputation beyond repute
Default

Quote:
Originally Posted by neilwhite View Post
When I run it, it includes the very top level folder that the document is saved in.
01 comes up as '01 This Folder', I should get '01 Introduction' and I get '01.01 Introduction\' instead.
I had assumed you would be running the macro from a folder below your 'Introduction' folder, in which case, '01 This Folder' is technically correct, though I'd have omitted the numbering from that heading level.
Change:
.InsertAfter vbCr & "This Folder" & vbCr
to:
.InsertAfter vbCr & Split(StrFldr, "\")(UBound(Split(StrFldr, "\"))) & vbCr

Regarding the '01.01 Introduction\' issue -
Change:
.InsertAfter vbCr & strRelPath & vbCr
to:
.InsertAfter vbCr & Split(strRelPath, "\")(0) & vbCr
Quote:
Originally Posted by neilwhite View Post
Finally the hyperlinks don't now work!
I get a 'security concern' pop up which I accept then I get 'an unexpected error has occurred' error.
Does this occur with hyperlinks to Word documents, or only with hyperlinks to other file types?

If it's the latter, that's most likely because when you use Word to hyperlink to another file type, Windows recognises there's an issue, then Word's attempt to open the file fails.
__________________
Cheers,
Paul Edstein
[Fmr MS MVP - Word]
Reply With Quote