Damaged document after saving...

J

Jeffery B Paarsa

Hello,

After editing and transfering edited data from UserForm to the document I
print and save the document. Printed document is normal and I have no
problem with it but I can not open the saved document and I get the following
error...
=====
The Office Open.XML file (Paarsa)(20081224100915).doc cannot be opened
because there are problems with the contents. Ok & Details <<<< buttons

Details ---------
Unspecified error
Location: Part:/word/header2.xml, Line:2, Column:3234
=====

Here is the part of code that saves and print document:
++++++
Memo.CheckSpelling
' ActiveDocument.Fields.Update
Memo.Fields.Update
Set BMRange = Memo.Bookmarks("ToRecip").Range
Pforms.ToRecip.Text = BMRange
Set BMRange = Memo.Bookmarks("ReSub").Range
Pforms.ReSub.Text = BMRange
Set BMRange = Memo.Bookmarks("MemoGreating").Range
Pforms.MemoGreating.Text = BMRange
Set BMRange = Memo.Bookmarks("MemoBody").Range
Pforms.MemoBody.Text = BMRange
Set BMRange = Memo.Bookmarks("MemoClosing").Range
Pforms.MemoClosing.Text = BMRange
.Bookmarks("AddrL1").Range _
.InsertBefore AddrL1
.Bookmarks("AddrL2").Range _
.InsertBefore AddrL2
.Bookmarks("Phone").Range _
.InsertBefore Phone
.Bookmarks("Fax").Range _
.InsertBefore Fax
.Bookmarks("WebURL").Range _
.InsertBefore WebURL
' ActiveDocument.Fields.Update
' Memo.Fields.Update
.Protect wdAllowOnlyFormFields, Noreset:=True
If Pforms.MSave.Value = False Then
Else
Dim SaveDocName As String
SaveDocName = Application.MacroContainer.Path + "\SavedDocs\(" +
Pforms.PLName.Text + ")(" + Format(Date, "YYYYMMDD") + Format(Time, "HHMMSS")
+ ").doc"
Memo.SaveAs FileName:=SaveDocName
End If
If Pforms.M2Copy.Value = True Then
.PrintOut Copies:=2
Else
.PrintOut
End If
Memo.Close wdDoNotSaveChanges
Pforms.Memo.Value = False
End With
End Sub
++++++
 
T

Tony Jollans

I can't be certain from only seeing part of the code, but there doesn't
appear to be anything there that affects any header, and corruption
shouldn't be routinely occurring. If you do have code that routinely causes
Word to create a corrupt document I would be interested to see all of it -
perhaps you could send me a copy, along with related documents and
templates.
 

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