Results 1 to 5 of 5
  1. #1
    4 Star Lounger
    Join Date
    Feb 2002
    Location
    Auckland, New Zealand
    Posts
    543
    Thanks
    56
    Thanked 0 Times in 0 Posts

    New page when template used (MSO 2003 wXPP)

    Hi
    I have written a macro under Word that has a userform with 5 option buttons on to select a template fro use. It works fine except when the userform is unloaded Word reverts to display the document that was open when the macro was invoked not the new document.

    How can I force Word to show the new document, as I know staff will just get confused.

    cheers
    cheers

    Phil Carter

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

    Re: New page when template used (MSO 2003 wXPP)

    Declare a variable of type Document.
    Set this variable when you create a new document from the selected template.
    Activate the document at the end.

    Dim doc As Document
    ...
    Set doc = Documents.Add(<selected template>)
    ...
    doc.Activate

  3. #3
    4 Star Lounger
    Join Date
    Feb 2002
    Location
    Auckland, New Zealand
    Posts
    543
    Thanks
    56
    Thanked 0 Times in 0 Posts

    Re: New page when template used (MSO 2003 wXPP)

    Hans thanks for that.

    I thought it was cracked but when I reran it there was no difference. As soon as the userform is unloaded it reverts to the original document.

    I am using this under the Select Case statement with doc.Activate following End Select.
    cheers

    Phil Carter

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

    Re: New page when template used (MSO 2003 wXPP)

    Could you post a stripped down and zipped copy of the document or template that contains the userform and macro? No need to include the templates the user can choose from, I can substitute other ones.

  5. #5
    4 Star Lounger
    Join Date
    Feb 2002
    Location
    Auckland, New Zealand
    Posts
    543
    Thanks
    56
    Thanked 0 Times in 0 Posts

    Re: New page when template used (MSO 2003 wXPP)

    Hans

    Problem resolved.

    I placed the doc.Activate after the userform unload command and this worked just fine.

    Thank you once again for your assistance.

    Regards
    cheers

    Phil Carter

Posting Permissions

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