Word Macro Keeps Running After SaveAs Dialog Box Despite F8

rvfowler2
rvfowler2 used Ask the Experts™
on
I am debugging a Microsoft Word macro on a Win 7 PC.  After the dlg.Show (sixth step below) when I click the OK button on the SaveAs dialog box, it runs continuously until finished despite the fact I hit F8.  Tried 3x now.  It never used to do this.  I haven't changed anything in the script for over a month.  Not sure how I'm supposed to debug the script when it won't continue step by step with F8.  Suggestions?


    '-----------
    Dim dlg As Dialog
    'Dim sFileName As String
    'sFileName = SaveCDP_Value & "_rr.doc"
    Set dlg = Dialogs(wdDialogFileSaveAs)
    dlg.Name = strFileName
    dlg.Show
    '-----------
       
    Selection.Find.ClearFormatting
    With Selection.Find
        .Text = "^t"
        .Replacement.Text = ""
        .Forward = True
        .Wrap = wdFindContinue
        .Format = False
        .MatchCase = False
        .MatchWholeWord = False
        .MatchWildcards = False
        .MatchSoundsLike = False
        .MatchAllWordForms = False
    End With
    Selection.Find.Execute
    Selection.Delete Unit:=wdCharacter, Count:=1
    Selection.HomeKey Unit:=wdStory, Extend:=wdExtend
    Selection.Cut
Comment
Watch Question

Do more with

Expert Office
EXPERT OFFICE® is a registered trademark of EXPERTS EXCHANGE®
Qlemo"Batchelor", Developer and EE Topic Advisor
Top Expert 2015

Commented:
Selection might not be set, and the script execution is stopped completely. What's your On Error setting?

Author

Commented:
There is no selection set or "On Error" setting that I know of.  F8 or Step Into works fine, stepping through one line at a time until I get to the SaveAs step, then after I click OK, it continues throughout the rest of the macro, almost as if I hit F5 "Continue." See screen print.
-WordMacro.jpg
Qlemo"Batchelor", Developer and EE Topic Advisor
Top Expert 2015

Commented:
Are you certain the remaining lines are executed?
Ensure you’re charging the right price for your IT

Do you wonder if your IT business is truly profitable or if you should raise your prices? Learn how to calculate your overhead burden using our free interactive tool and use it to determine the right price for your IT services. Start calculating Now!

Author

Commented:
Yes, because I can see how they effect the Word document that is open right in front of me.

Author

Commented:
Very strange.  Never used to do that.
"Batchelor", Developer and EE Topic Advisor
Top Expert 2015
Commented:
How about setting a breakpoint at one of the "skipped" lines? Does that work at least?
There weren't any "skipped" lines.  Problems is that it just keeps running through the lines even though I only pressed F8 for Step Info which usually processes one line a time.  However, took your advice and set a breakpoint, and that worked.  After I clicked OK on the SaveAs dialog box, it only ran to the breakpoint and stopped.  At least now I have a way of stopping it.  Thanks.
Qlemo"Batchelor", Developer and EE Topic Advisor
Top Expert 2015

Commented:
That's what I meant. But I've still no clue why F8 does not work.

Author

Commented:
Thanks for the help.  At least setting a breakpoint works.  Will keep researching why F8 Step Into no longer goes one line at a time.

Do more with

Expert Office
Submit tech questions to Ask the Experts™ at any time to receive solutions, advice, and new ideas from leading industry professionals.

Start 7-Day Free Trial