• Default title for new document (Word 2000 SR-1)

    Home » Forums » AskWoody support » Productivity software by function » MS Word and word processing help » Default title for new document (Word 2000 SR-1)

    Author
    Topic
    #372535

    Normally, on a new document, Word uses the first few words as a default title when saving the document for the first time. Is there any way to get Word to use words from a field on the document instead?

    Viewing 0 reply threads
    Author
    Replies
    • #595866
      Sub ChangeDocTitle()
            'Get the title from fields, prompts, date, etc...whatever!
            newTitle = ActiveDocument.FormFields("AnyFormField").Result  
            With Dialogs(wdDialogFileSummaryInfo)
               .Title = newTitle
               .Execute
            End With
      End Sub

      Don’t bother trying to set the Title property directly in VB. If you don’t go through the dialog box it doesn’t always work. V. frustrating.

      • #596010

        Thanks for the response; unfortunately, I asked the wrong question (my apologies). doh Let’s try this again…

        What I really wanted to do was to take the text from the form field and use it for the default file name when saving the document; i.e., Form Field Text.doc. Can this be done in a similar manner?

        • #596034

          Going with what you already have, is this what you’re looking for?

          Sub TestSave()
              Dim FileName As String
          'This pulls the name from your 'AnyFormField' field
              FileName = ActiveDocument.FormFields("AnyFormField").Result    
          'Show the SaveAs dialog box
              With Dialogs(wdDialogFileSaveAs)
          'with your suggested filename
                  .Name = FileName & ".doc"
                  .Show
              End With
          End Sub
          
        • #596253

          Oh, yes! Actually that’s what I was doing there. See, if you have text entered in the Document’s Title properties (File…Properties…Title) then when the user saves the file the FIRST time it will use that text instead of the first few words of the document.

          I like to do that so the user can save whenever they want. But the macro to replace the save command works too. 🙂

          • #596270

            What’s crazy is that the suggested name corresponds to the Title property if I enter it manually, but not if I set it in a macro:
            ActiveDocument.BuiltInDocumentProperties(wdPropertyTitle) = “New title”

            Am I missing something? Or is this a bug?

            cheersKlaus

            • #596699

              Yup. It’s a bug (I think!) AND you’re missing something.

              “Don’t bother trying to set the Title property directly in VB. If you don’t go through the dialog box it doesn’t always work. V. frustrating.” You can use VB to enter the text in the dialog box using the code I posted above.

            • #596794

              Oh, I must have missed that part wink

              Sorry, Klaus

          • #596332

            Worked like a charm! Thanks to all.

    Viewing 0 reply threads
    Reply To: Default title for new document (Word 2000 SR-1)

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

    Your information: