none
VBA 4198 error command fail with ActiveDocument.Save RRS feed

  • Question

  • I am getting 4198 error run time error with on the ActiveDocument.Save line below

        If optSave.Value Then                                   '   If save & close option selected...
            'Change the status of the Normal template to unchanged. If changes were
            '   made to the Normal template, the changes are not saved when you exit Word.
            NormalTemplate.Saved = True
            ' Prevent ActiveDocument from reporting that it has changed
            ActiveDocument.AttachedTemplate.Saved = True
            If frmAssemble.optCtlA_F9 Then
                ' Prevent Document too big to spell check error by setting current spell check to true.
                ActiveDocument.SpellingChecked = True
                ActiveDocument.ShowSpellingErrors = False
                ' Perform Ctrl A followed by F9 equivalent to update all the document fields
                Selection.WholeStory        ' Ctrl-A = Select the entire document
                Selection.Fields.Update     ' F9
                Selection.EscapeKey         ' Undo Select all
                Selection.Collapse Direction:=wdCollapseStart
            End If
            If ActiveDocument.Revisions.Count >= 1 Then
                'This should not happen
                MsgBox Prompt:="Accepting " & ActiveDocument.Revisions.Count & " in " & ActiveDocument.Name & ".", _
                    Buttons:=vbInformation, Title:="Saving Finished Assembly"
                ActiveDocument.AcceptAllRevisions
            End If
            ' Prevent ActiveDocument from reporting that it has changed
            ActiveDocument.AttachedTemplate.Saved = True
            ' Trap final save errors
            On Error GoTo FinalSaveError
            ' Save the new document
            ActiveDocument.Save
            ' Turn off Trapping
            On Error GoTo 0
            DeltaStopTime = Timer
            DisplayStatus "Save Time:  " & Elapsed(DeltaStartTime, DeltaStopTime)
            'Reset Delta Start Timer
            DeltaStartTime = DeltaStopTime
        End If

    The document contains embedded word documents and excel documents and works fine until enough other sections are added so that the created file is about 5 Meg.  The final document should be 10 meg.   If I remove the embedded documents it works.  If I trap  the 4198 code and use resume next the first save turns to a save as.   On exiting word the program will request to save multiple times.    My guess is one for every object embedded (11).   What is wrong?

    Friday, February 13, 2015 1:16 AM

All replies

  • Hi RN

    Could you please provide the error message you're getting? There's no convenient (public) source for error numbers and messages to look it up...

    If you try to save this kind of document as an end-user do you also encounter problems? Does doing that provide any additional information about what's bothering Word?

    Which version of Word is involved with the problem?

    Could you please be specific about what you mean by "other sections are added": What (type of content) is being added?


    Cindy Meister, VSTO/Word MVP, my blog

    Friday, February 13, 2015 8:08 PM
    Moderator