Results 1 to 3 of 3
  1. #1
    New Lounger
    Join Date
    Apr 2008
    Posts
    3
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Msgbox when opening Word + fields (Word 2003 + VBA)

    <P ID="edit" class=small>(Edited by StanAalbers on 16-Apr-08 10:47. Forgot to explain what I wanted to do with the fields)</P>dear people,

    I would like to create a word document with fields where some other person can fill out info. Protected, so he/she can't mess with the rest. I know how to insert the fields, but can I do the following:

    1. The person who fills it out, fills out his company name (e.g. XYZ Inc) in the respective field;
    2. What he filled out there, should be used to save the file: (e.g. the file name should be: NCBP [company name] & [TODAY] (resulting in "NCBP XYZ Inc 160408"

    Secondly, I would like to have a message box opened when that Word file is opened. But I can not get it to work. can someone get me on track here?

    I have built VBA for excel (moderate level), but I can not get this Word to work.

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

    Re: Msgbox when opening Word + fields (Word 2003 + VBA)

    Welcome to Woody's Lounge!

    I have attached a template (Sample.dot, zipped). Unzip the file, then double click the template. You'll see a message box. This is done through a Document_New event procedure in the ThisDocument module (the Word equivalent of Excel's ThisWorkbook).

    Private Sub Document_New()
    MsgBox "Please fill in the company name and press Tab before saving the document", vbInformation
    End Sub

    There is a form field named Company. In its properties, the SetTitle macro has been specified to be run when the user exits the form field, i.e. when the user presses Tab or clicks somewhere else. The SetTitle macro is stored in a standard module and it looks like this:

    Sub SetTitle()
    With Dialogs(wdDialogFileSummaryInfo)
    .Title = "NCBP " & ActiveDocument.FormFields("Company").Result & " " & Format(Date, "ddmmyy")
    .Execute
    End With
    End Sub

    This sets the suggested name for when the user first saves the file.
    Attached Files Attached Files

  3. #3
    New Lounger
    Join Date
    Apr 2008
    Posts
    3
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Re: Msgbox when opening Word + fields (Word 2003 + VBA)

    Great Hans! It works as well in my document!

    Took some time to figure out that I had to save the document as a template, but I got it. Thanks for your help, much appreciated.

Posting Permissions

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