0

How do I have a link within a word document to certain text strings of the file name?

For example, I am editing a word document where the file name is: 'File 075 - Test result 101.doc', and would like to only use the strings 'File 075' rather than the full file name in the word document as a automatic link / field that updates itself when the file name changes.

How would you proceed with it?

2
  • Can you provide some more detail about what you are trying to do? To what do you want to link? Do you just want to extract the information before the hyphen in the file name and show that as text in the document? Aug 2, 2010 at 0:15
  • @Wayne Johnston: I think he means link to part of the filename, so that when the filename changes, so does the document text.
    – Zaz
    Aug 2, 2010 at 0:58

2 Answers 2

0

I think you are talking about a field and not a link as in hyperlink. A hyperlink can have its display text different from its url. A field cannot change its display text though.

0

There is no field or feature in word to split text and display the result. However you can achieve this by using a VBA macro.

The macro will need to be shipped with the document. If you are unfamiliar with them you will also need to do some reading up on the subject.

Something like this. The bookmark "MyBookmark" is where you want the left part of the file name to appear.

Dim name As String
name = name + Split( _
    ActiveDocument.Name, "-")(0)

ActiveDocument.Bookmarks("MyBookmark").Range.Text = name

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .