Results 1 to 6 of 6
  1. #1
    New Lounger
    Join Date
    Jan 2003
    Location
    Fort Worth, Texas, USA
    Posts
    22
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Do you want to create another? (VBA/WordXP)

    I have a template where 8 fields are filled in. After the last field is filled in, I ask the question "Do you want to create another document?" If the answer is YES, I only want 2 fields changed and the other fields to remain the same. I have no idea how to do this. Can someone give me some help. And all help will be appreciated.

    <img src=/S/stupidme.gif border=0 alt=stupidme width=30 height=30>

  2. #2
    5 Star Lounger
    Join Date
    May 2001
    Location
    Stuttgart, Baden-W, Germany
    Posts
    931
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Re: Do you want to create another? (VBA/WordXP)

    Hi Gwynne,

    You can use MsgBox.
    Try something like this:

    <pre>Dim Answer As Integer
    Answer = MsgBox("Do you want to create another document?", vbQuestion + vbYesNo)
    If Answer = vbYes Then
    MsgBox "You clicked ""Yes""", vbInformation
    Else
    MsgBox "You clicked ""No""", vbInformation
    End If</pre>

    <img src=/S/cheers.gif border=0 alt=cheers width=30 height=16> Klaus

  3. #3
    Super Moderator jscher2000's Avatar
    Join Date
    Feb 2001
    Location
    Silicon Valley, USA
    Posts
    23,112
    Thanks
    5
    Thanked 93 Times in 89 Posts

    Re: Do you want to create another? (VBA/WordXP)

    It might help if you write out the exact sequence of events you envision at a level that the machine (or a progammer) could work with. <img src=/S/grin.gif border=0 alt=grin width=15 height=15> In particular, where is the Save or SaveAs in this process, and would there be any harm in creating the second document using SaveAs rather than starting from scratch with the template again?

  4. #4
    5 Star Lounger
    Join Date
    May 2001
    Location
    Stuttgart, Baden-W, Germany
    Posts
    931
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Re: Do you want to create another? (VBA/WordXP)

    Right: I had problems, too, figuring out what was being done, and how (document protected for forms? User Form? Wizard?)

    I went with the interpretation that this is for some kind of wizard that asks information from the user, one after the other.

    It might also be a document protected for forms ... but how would you make sure that all (previous?) eight fields have been filled in?

    And what do you mean with
    "[...] 8 fields are filled in [...] I only want 2 fields changed and the other fields to remain the same."?

    Do you want to make changes to two fields? Or do you want to discard the changes that the user made in 6 fields?

    <img src=/S/cheers.gif border=0 alt=cheers width=30 height=16> Klaus

  5. #5
    2 Star Lounger
    Join Date
    Feb 2001
    Location
    Brussels, Brussel, Belgium
    Posts
    159
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Re: Do you want to create another? (VBA/WordXP)

    I'm assuming she wants to create a copy of the document, keep 6 fields with the information as has been filled in in the 1st document and then change the two remaining fields.
    a copy of the activedocument can only be made if you save it. all the changes you made after the save will also be copied though.

    so you could create something like this :

    <pre>Sub CreateCopyOfActiveDocument()
    'first save the document
    'saveas dialog will pop up if it's
    'the first time
    ActiveDocument.Save
    'create a copy of the document with all
    'the changes that have been applied by the
    'user or a macro to text & fields & stuff
    'if you do not want to run automacros
    'enable the following line by decommenting
    'the wordbasic statement:
    '-----------------------------
    'wordbasic.disableautomacros 1
    '-----------------------------
    Documents.Add ActiveDocument.FullName
    'reenable automacros if you previously
    'disabled them
    '-----------------------------
    'wordbasic.disableautomacros 0
    '-----------------------------
    'now clear the fields 7 & 8 on the
    'copy of the document
    ActiveDocument.FormFields(7).Result = ""
    ActiveDocument.FormFields(8).Result = ""
    End Sub
    </pre>


  6. #6
    New Lounger
    Join Date
    Jan 2003
    Location
    Fort Worth, Texas, USA
    Posts
    22
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Re: Do you want to create another? (VBA/WordXP)

    Thanks, guys. Everyone is so helpful, and I feel so stupid <img src=/S/bagged.gif border=0 alt=bagged width=22 height=22> !!!

    Special thanks to Pieter for being able to read my mind (what little is left). Suggestions from Klaus and Pieter will get me started down the right path.

Posting Permissions

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