Results 1 to 4 of 4
  1. #1
    New Lounger
    Join Date
    Aug 2014
    Posts
    2
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Word 2010: Using {FILENAME} inside a hyperlink

    I have been searching and searching for an answer but cannot seem to find something similar to my situation. I am trying to add a couple of relative hyperlinks that contain the same name as the current file but have different extensions. Every time I try to do this it will work but after closing and opening the document one of the links change to absolute.

    example-
    { HYPERLINK "FolderA/{ FILENAME }.mp3" }
    { HYPERLINK "FolderB/{ FILENAME }.xlsx" }

    after saving, closing and reopening the document it becomes

    { HYPERLINK "FolderA/filename.mp3" }
    { HYPERLINK "FolderB/{ FILENAME }.xlsx" }

    It appears that { FILENAME } can only be saved in one spot (and thus only the newest one stays) but I cannot find any documentation supporting this. Any help with this or suggestions for a different approach would be very helpful.

  2. #2
    Super Moderator
    Join Date
    May 2002
    Location
    Canberra, Australian Capital Territory, Australia
    Posts
    5,055
    Thanks
    2
    Thanked 417 Times in 346 Posts
    A FILENAME field can be used in a hyperlink field, but you can't use it the way you're doing. That's because a FILENAME field returns the file's name and extension. So, you'd never get the equivalent of 'HYPERLINK "FolderA/filename.mp3' but 'HYPERLINK "FolderA/filename.docx.mp3'.
    Cheers,

    Paul Edstein
    [MS MVP - Word]

  3. #3
    Super Moderator
    Join Date
    Jan 2001
    Location
    Melbourne, Victoria, Australia
    Posts
    3,853
    Thanks
    4
    Thanked 259 Times in 239 Posts
    It looks like you either need to use a macro to populate the hyperlink paths or turn on the Windows setting to 'Hide file extensions for known file types'

    I would recommend the macro option.
    Andrew Lockton, Chrysalis Design, Melbourne Australia

  4. #4
    New Lounger
    Join Date
    Aug 2014
    Posts
    2
    Thanks
    0
    Thanked 0 Times in 0 Posts
    Thanks for the replies. I ended up using an AutoOpen() macro that finds the location for the hyperlink and adds it using ActiveDocument.Path for the relative part and .Variables("FileName").Value = Left(.Name, InStrRev(.Name, ".") - 1) for the filename part.

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •