• Replacing a File Property with Bookmark Content

    Home » Forums » AskWoody support » Productivity software by function » MS Word and word processing help » Replacing a File Property with Bookmark Content

    Author
    Topic
    #456673

    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.

    Viewing 1 reply thread
    Author
    Replies
    • #1141937

      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.

      • #1141968

        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!

      • #1142039

        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?

        • #1142050

          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.

    • #1141954

      > 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

    Viewing 1 reply thread
    Reply To: Replacing a File Property with Bookmark Content

    You can use BBCodes to format your content.
    Your account can't use all available BBCodes, they will be stripped before saving.

    Your information: