Word 2002 crash on exit

S

Saffdawg

Scenario: Users will have more than one document open, edit the document,
print and close (using File-Exit, file-close, the "little" x, or the "red"
X) and word will crash. The error is "MS Word has encountered a
problem and needs to close. We are sorry for the inconvenience." The
details of the message are:

AppName: winword.exe AppVer: 10.0.5815.0 ModName: winword.exe
ModVer: 10.0.5815.0 OffSet: <varies>

All word documents that had been open are forced to close and "recovery" of
these documents takes an extended amount of time.

We have a macro that runs when users use the File-Print or Printer icon,
which, if they choose "Yes" in a Dialog box, will insert a text box in the
footer of the document.

It seems that if the user chooses "No", or has only one document open while
printing, no errors occur. The word crash only happens when closing the
document after inserting the text box, if there is more than one document
open.

Any ideas?

Thanks.
 
B

Beth Melton

If the crash only occurs when you use the macro then more than likely
there is a problem in your code.

Can you provide us with the code you are using?

--
Please post all follow-up questions to the newsgroup. Requests for
assistance by email can not be acknowledged.

~~~~~~~~~~~~~~~
Beth Melton
Microsoft Office MVP

Word FAQ: http://mvps.org/word
TechTrax eZine: http://mousetrax.com/techtrax/
MVP FAQ site: http://mvps.org/
 
S

Saffdawg

Thanks for looking at this....

Here is the code

Const cDOCTEXT = "Document ID: "

' This File-Print subroutine is the same as the FilePrintDefault()

Sub FilePrint()
Dim SaveView As Integer
Dim yesno As Integer

SaveView = ActiveWindow.View.Type

Application.ScreenUpdating = False

If ActiveWindow.View.SplitSpecial = wdPaneNone Then
ActiveWindow.ActivePane.View.Type = wdPrintView
Else
ActiveWindow.View.Type = wdPrintView
End If

yesno = MsgBox("Include document name in footer?", vbYesNo, "Document
Footer")

If yesno = vbYes Then
Module1.InsertFooter ' Calls the Insert Footer Subroutine
Else
Module1.DeleteFooter
ActiveDocument.Sections(1).Headers(wdHeaderFooterPrimary)
End If

With ActiveWindow.View
.Type = wdNormalView
.Type = SaveView
End With

Application.ScreenUpdating = True

Dialogs(wdDialogFilePrint).Show
End Sub

Sub DeleteFooter(DocFooter As HeaderFooter)
On Error Resume Next
Dim myShape As Shape
For Each myShape In DocFooter.Shapes
If Left(myShape.Name, 4) = "Text" Then myShape.Delete
Next myShape
End Sub

Sub InsertFooter()
On Error GoTo Err
Dim DocName As String
Dim EndPos As Integer
Dim mySection As Section
Dim myShape As Shape
Dim StartRange As Range

DocName = ActiveDocument.FullName
Application.ScreenUpdating = False

Set StartRange = Selection.Range
StartRange.Collapse (wdCollapseEnd)

Set mySection = ActiveDocument.Sections(1)

ActiveWindow.View.Type = wdPageView

DeleteFooter mySection.Footers(wdHeaderFooterPrimary)

If ActiveDocument.Sections(1).PageSetup.DifferentFirstPageHeaderFooter
Then
ActiveWindow.ActivePane.View.SeekView = wdSeekFirstPageFooter
InsertStamp cDOCTEXT & DocName, Selection.HeaderFooter, mySection
End If

ActiveWindow.ActivePane.View.SeekView = wdSeekPrimaryFooter
InsertStamp cDOCTEXT & DocName, Selection.HeaderFooter, mySection

StartRange.Select
Exit Sub
Err:
If Err.Number = 5895 Then
StartRange.Select
Exit Sub
Else
MsgBox "You have not saved your document. Your document will be
printed without document information "
ActiveWindow.ActivePane.View.SeekView = wdSeekMainDocument
End If
End Sub

' Inserts Text box into footer

Private Sub InsertStamp(DocName As String, DocFooter As HeaderFooter,
mySection As Section)
Dim lmdblt As Template
Dim myRange As Range
Dim Stamp As Shape
Dim FileName As String
Dim Version As String
Dim SubVersion As String

'Style Check Variables
Dim myStyle As Style
Dim styCheck As Boolean

'Check for FooterName Style
For Each myStyle In ActiveDocument.Styles
If myStyle = "FooterName" Then
styCheck = True
End If
Next myStyle

'Make FooterName Style if it doesn't Exist
If styCheck <> True Then
ActiveDocument.Styles.Add Name:="FooterName",
Type:=wdStyleTypeParagraph
ActiveDocument.Styles("FooterName").AutomaticallyUpdate = False
With ActiveDocument.Styles("FooterName")
.BaseStyle = ActiveDocument.Styles(wdStyleNormal)
End With
With ActiveDocument.Styles("FooterName")
.AutomaticallyUpdate = False
.BaseStyle = "Normal"
End With
With ActiveDocument.Styles("FooterName").ParagraphFormat
.Alignment = wdAlignParagraphLeft
End With
With ActiveDocument.Styles("FooterName").Font
.Size = 8
End With
End If
Set Stamp = DocFooter.Shapes.AddTextbox(msoTextOrientationHorizontal,
mySection.PageSetup.LeftMargin, _
mySection.PageSetup.PageHeight - 36, 200, 24)
With Stamp
.TextFrame.TextRange.Style = "FooterName"
.TextFrame.TextRange.Text = DocName & " " & Format(Now)

.Line.Visible = msoFalse
End With

End Sub
 
B

Beth Melton

I just tried your code in Word 2002 and was unable to duplicate the
behavior. However there are two things that come to mind, under
Tools/Options/Print do you have "Background printing" selected? If so
does turning this option off prevent the crash?

Also, do you have all of the patches installed? Take look under
Help/About Microsoft Word and provide the full version number.

--
Please post all follow-up questions to the newsgroup. Requests for
assistance by email can not be acknowledged.

~~~~~~~~~~~~~~~
Beth Melton
Microsoft Office MVP

Word FAQ: http://mvps.org/word
TechTrax eZine: http://mousetrax.com/techtrax/
MVP FAQ site: http://mvps.org/
 
S

Saffdawg

Yep. Tried to turn background printing off and would still get the crash.

The version says Microsoft Word 2002 (10.5815.4219) SP-2

Thanks.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top