Results 1 to 5 of 5
  1. #1
    Bronze Lounger
    Join Date
    Jan 2001
    Location
    Melbourne, Australia
    Posts
    1,294
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Merged document doesnt run local code (OfficeXP SP3)

    Hi

    I have local and global templates.

    My local template is Letter.dot with its own modules:
    Autonew
    AutoOpen
    FilePrint
    FilePrintDefault &
    Main

    In the template ff theres code within the module FilePrint > it will run this code. ie display a custom print dialog.
    However if no code exists within the local module FilePrint> then it wil goto the global template which has the module FilePrint & dispaly the standard print dialog.

    My issue is:
    If I do a Mail merge on my letter. In the merged letter document when I do a FilePrint> it bypasses the local code (ignores it completely) and runs the global FilePrint code.

    I have put in the following workaround code:
    With ActiveDocument
    .AttachedTemplate = _
    BaseLocationForTemplates & "Letter.dot"
    End With

    but still no success.
    any ideas on how I can resolve this?
    many thanks Diana

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

    Re: Merged document doesnt run local code (OfficeXP SP3)

    I see the same behavior - strange. Does this work for you?

    With ActiveDocument
    .AttachedTemplate = "Normal"
    .AttachedTemplate = BaseLocationForTemplates & "Letter.dot"
    End With

    By temporarily setting the attached template to Normal, then setting it back to the Letter template, you force Word to read the template again.

  3. #3
    Bronze Lounger
    Join Date
    Jan 2001
    Location
    Melbourne, Australia
    Posts
    1,294
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Re: Merged document doesnt run local code (OfficeXP SP3)

    Thanks for that Hans.

    Yes Ive placed that code in the local Letter template in the custom print form in Private Sub UserForm_Initialize().

    The issue is > the local template code - the module 'FilePrint' doesnt run to call the local custom print form.

    Another solution i was applying was in my global template in the module FilePrint > test if the document document is attached to the letter template. If true then run the following code:
    Application.Run MacroName:="Letter.FilePrint.Main"

    However when I step thru the code & it gets to the above line - it bombs. I dont know why?

    And another solution was in my global template just add the local letter print custom dialog box so it can get called & displayed. This means the custom print form is in 2 locations - which means more maintenance etc. at least it will solve the issue?

    what do you think?
    diana

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

    Re: Merged document doesnt run local code (OfficeXP SP3)

    You can't place the code to detach and reattach the local template in the local template itself - the moment you detach the template, the code stops runninng, so the reattach never takes place.

    Unless someone else has a bright idea, putting the custom print dialog in the global template may be the best thing to do, however inelegant. <img src=/S/sorry.gif border=0 alt=sorry width=15 height=15>

  5. #5
    Bronze Lounger
    Join Date
    Jan 2001
    Location
    Melbourne, Australia
    Posts
    1,294
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Re: Merged document doesnt run local code (OfficeXP SP3)

    hey hans

    thanks for that.
    yeah i'll go with the option of placing the local form in the global template - that will work.

    cheers...have a good day
    diana :-)

Posting Permissions

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