Word Macro Keeps Running After SaveAs Dialog Box Despite F8

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
LVL 2
rvfowler2Asked:
Who is Participating?
 
QlemoBatchelor, Developer and EE Topic AdvisorCommented:
How about setting a breakpoint at one of the "skipped" lines? Does that work at least?
0
 
QlemoBatchelor, Developer and EE Topic AdvisorCommented:
Selection might not be set, and the script execution is stopped completely. What's your On Error setting?
0
 
rvfowler2Author 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
0
Cloud Class® Course: SQL Server Core 2016

This course will introduce you to SQL Server Core 2016, as well as teach you about SSMS, data tools, installation, server configuration, using Management Studio, and writing and executing queries.

 
QlemoBatchelor, Developer and EE Topic AdvisorCommented:
Are you certain the remaining lines are executed?
0
 
rvfowler2Author Commented:
Yes, because I can see how they effect the Word document that is open right in front of me.
0
 
rvfowler2Author Commented:
Very strange.  Never used to do that.
0
 
rvfowler2Author Commented:
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.
0
 
QlemoBatchelor, Developer and EE Topic AdvisorCommented:
That's what I meant. But I've still no clue why F8 does not work.
0
 
rvfowler2Author 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.
0
Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.

All Courses

From novice to tech pro — start learning today.