Take the 2-minute tour ×
Super User is a question and answer site for computer enthusiasts and power users. It's 100% free, no registration required.

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?

share|improve this question
    
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? –  Wayne Johnston Aug 2 '10 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. –  Josh Aug 2 '10 at 0:58

2 Answers 2

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.

share|improve this answer

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
share|improve this answer

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.