Results 1 to 6 of 6
  1. #1
    2 Star Lounger
    Join Date
    Feb 2001
    Location
    McLean, VA
    Posts
    125
    Thanks
    4
    Thanked 0 Times in 0 Posts

    Replacing a File Property with Bookmark Content

    I would like users of my templates to be prompted to name their documents based on the content of a bookmark (usually one called DocNumber, but it could be a different one), which the user populates at file open via a userform. It appears to me that the Title file property is what needs to be changed. I have researched how to manually change file properties, and also how to create custom properties, but I couldn't find any guidance on replacing a property with bookmark content. When the user selects File > Save As, I want the content of the bookmark (usually a document number) to be pre-filled in the File Name box.

  2. #2
    Plutonium Lounger
    Join Date
    Mar 2002
    Posts
    84,353
    Thanks
    0
    Thanked 29 Times in 29 Posts

    Re: Replacing a File Property with Bookmark Content

    You can use a macro like this:

    Sub SetProposedFilename()
    With Dialogs(wdDialogFileSummaryInfo)
    .Title = ActiveDocument.Bookmarks("DocNumber").Range.Text
    .Execute
    End With
    End Sub

    See How to set the default suggested filename to be displayed by the Save As dialog the first time a user saves a new document for the reason I used Dialogs(wdDialogFileSummaryInfo) instead of the documents Title property.

  3. #3
    Plutonium Lounger
    Join Date
    Nov 2001
    Posts
    10,550
    Thanks
    0
    Thanked 7 Times in 7 Posts

    Re: Replacing a File Property with Bookmark Content

    > I couldn't find any guidance on replacing a property with bookmark content.

    It won't help with this issue, but you can set the value of a Custom Document Property from a bookmark. Just go to the Custom tab, create the new property, check the box marked "Link to content" and choose the correct bookmark.

    Word will allow you to create a custom document property called "Title", but this is not used as the default file name, that has to be the builtin property called "Title" - and I can't see any way to associate this one with a bookmark.

    StuartR

  4. #4
    2 Star Lounger
    Join Date
    Feb 2001
    Location
    McLean, VA
    Posts
    125
    Thanks
    4
    Thanked 0 Times in 0 Posts

    Re: Replacing a File Property with Bookmark Content

    Worked like a charm as usual, Hans! I pasted the inner 4 lines of your macro to the end of the userform's CommandButton code. The replacement of the value of the Title file property is completely transparent to the user. THANKS!

  5. #5
    2 Star Lounger
    Join Date
    Feb 2001
    Location
    McLean, VA
    Posts
    125
    Thanks
    4
    Thanked 0 Times in 0 Posts

    Re: Replacing a File Property with Bookmark Content

    Well at least it worked like a charm from my home computer last night. Now that I'm at work, I've noticed that the document number is being cut off at the first hyphen (Title property CTIS-MIN-09-0001 results in CTIS.doc in the File Name box of the Save As dialog). Strange that it would work on one PC but not another (same versions of Word on each). I noticed in the MVPS article (which you supplied the link for) that delimiters such as underscores cause problems. I guess hyphens fall into this category as well. Is there any good workaround that would involve no extra work for the user?

  6. #6
    Plutonium Lounger
    Join Date
    Mar 2002
    Posts
    84,353
    Thanks
    0
    Thanked 29 Times in 29 Posts

    Re: Replacing a File Property with Bookmark Content

    I know that this will not be what you wanted to hear, but the "solution" is: don't use delimiters such as spaces, hyphens, underscores and punctuation in the proposed file name...

    Otherwise you'd have to write a lot of very kludgy code.

Posting Permissions

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