Issue with docvariables in header and footer

L

Lee Kiwiflame

I have Word 2003 templates that insert information from a user form into a
Word document. I use docvariables through the body, header and footer.
These templates have been working perfectly for a few years until we upgraded
to Word 2007 no so long ago.

The information is inserted correctly and is okay when you save and print
the document. However, if you re-open and re-print the document, the header
and footer docvariables change to funny characters (i.e.
hieroglphics*spelling?*).

I don't understand why this is happening or what could be the issue.

Also, the templates have issues when you try to do a mail merge. If you try
to use the mail merge wizard, all docvariable fields change to funny
characters when you print.

An example of my code is:

Private Sub CmdOK_Click()

'Set the value of the variables

strMain = frmDocument.TxtMain
strDate = Format(frmDocument.TxtDate, "d mmmm yyyy")

'Use variables to update Document Variables for merge fields

ActiveDocument.Variables("MainHeading").Value = strMain
ActiveDocument.Variables("PreparedDate").Value = strDate

'Update Fields

ActiveDocument.Fields.Update

Dim oSec As Section
For Each oSec In ActiveDocument.Sections
With oSec
.Headers(wdHeaderFooterPrimary).Range.Fields.Update
.Footers(wdHeaderFooterPrimary).Range.Fields.Update
End With
Next oSec

'Go to beginning of document
Selection.HomeKey Unit:=wdStory
ActiveDocument.ActiveWindow.View.Type = wdPrintView

End
End Sub

Sub UpdateFields()
ActiveDocument.Fields.Update
Options.UpdateFieldsAtPrint = True
End Sub

I have tried removing the UpdateFields() sub part but this makes no
difference.
 
L

Lee Kiwiflame

Sorry about double posting - I couldn't find the first post as it wasn't
showing in this site.
I've done it with a couple of postings as they were not showing.
 

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