View Single Post
 
Old 07-09-2024, 04:46 PM
WordUser789 WordUser789 is offline Windows 10 Office 2016
Novice
 
Join Date: Jun 2017
Posts: 25
WordUser789 is on a distinguished road
Default The command "ActiveDocument.AttachedTemplate" causes macro to skip to the end

I have a short macro that updates the styles in a document with those in the attached template:

Code:
With ActiveDocument
        .UpdateStylesOnOpen = True
        .AttachedTemplate = aTmp
    End With
    With ActiveDocument
        .UpdateStylesOnOpen = False
        .AttachedTemplate = aTmp
    End With
This works fine, however if I am using F8 to step through the code, once I press F8 on the .AttachedTemplate line, it will run the rest of the code to the end. Not such an issue with such a short macro however sometimes this is part of a larger macro. The only way I can check anything after it is to set another break point in the code after this step so it's forced to stop.

The other issue I'm finding is that when I run it as part of the larger macro and it is actually switching the URL of a template, it will run the first half (setting update styles to true) and then stop. Setting a breakpoint after the step in this instance doesn't have any effect: anything after it isn't run.

If I run the same macro again, it will complete all the steps: the only thing that's different is that it hasn't changed the template.

Any clues?
Reply With Quote