DocVaraible in Footer Issue

L

Lee Kiwiflame

I have many templates that have vba which were created in Word 2003.
However, since we upgraded to Word 2007, all templates that have a
docvariable field in the footer are now breaking.

The issue is that the footer docvariable is displaying correctly when you
save and print, however if you save again, close the document, open the
document and print again, I get funny characters in the docvariable, e.g.
Ò°x㊡䰜㊸᣿᣿᣿᣿ۿۿ㌀ۖĀÌ홪Ę蔀

My code to insert info from the user form is:

Private Sub cmdOK_Click()

strDate = Format(Now, "d MMMM yyyy")
strTitle = frmConfAgenda.txtTitle
strcommname = frmConfAgenda.CboCommittee
strrepoff = frmConfAgenda.txtRepOff
strreptitle = frmConfAgenda.TxtRepTitle
strconf = frmConfAgenda.txtConfidential
strmeetdate = FormatDateTime(frmConfAgenda.calMeetingDate.Value, vbLongDate)
strmeetdate2 = Format(frmConfAgenda.calMeetingDate.Value, "d MMMM yyyy")
strreason = frmConfAgenda.TxtReason
strcul = frmConfAgenda.TxtCultural
streco = frmConfAgenda.TxtEconomic
strenv = frmConfAgenda.TxtEnvironment
strsoc = frmConfAgenda.TxtSocial

'Populate the document

ActiveDocument.Variables("mission").Value = strreason
ActiveDocument.Variables("cultural").Value = strcul
ActiveDocument.Variables("eco").Value = streco
ActiveDocument.Variables("env").Value = strenv
ActiveDocument.Variables("social").Value = strsoc
ActiveDocument.Variables("date").Value = strDate
ActiveDocument.Variables("Title").Value = strTitle
ActiveDocument.Variables("Name").Value = strcommname
ActiveDocument.Variables("MeetDate").Value = strmeetdate
ActiveDocument.Variables("MeetDate2").Value = strmeetdate2
ActiveDocument.Variables("RepOff").Value = strrepoff
ActiveDocument.Variables("RepTitle").Value = "(" & strreptitle & ")"
ActiveDocument.Variables("Confidential").Value = strconf

'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
Selection.NextField.Select
Selection.Fields.Update
Selection.HomeKey Unit:=wdStory

ActiveDocument.ActiveWindow.View.Type = wdPrintView

End
End Sub

The fields I have in the footer are:

{ DOCVARIABLE Name \* MERGEFORMAT }
{ PAGE }
{ DOCVARIABLE MeetDate2 \* MERGEFORMAT }
{ FILENAME \p \* MERGEFORMAT }

The page and filename fields are okay, it's just the docvariables.

I'm also having the same issue with docvariable fields in the body of a
letter template. The funny characters only appear when they do a mail merge
based on the letter template, and it's only started happening since the
upgrade to Word 2007.

Any help appreciated!!!!!!!!!!! :)
 
D

Doug Robbins - Word MVP

I have experienced that issue on one machine that I use and as far as I can
tell, the main way in which that machine differs from others that I use is
that it has Right to Left text enabled.

Saving documents in Word 97-2003 format, rather than in *docx format,
however seems to avoid the problem.

--
Hope this helps

Doug Robbins - Word MVP
Please reply only to the newsgroups unless you wish to avail yourself of my
services on a paid, professional basis.
 
L

Lee Kiwiflame

Thanks Doug. What to mean by "Right to Left text enabled"?

I noticed that if I save as 97-2003 format then there is no issue, however,
that is not the ideal resolution as we can't save them with that format
forever :)

I just thought that there might be a website, blog or forum that identified
the difference of how Word 2003 and Word 2007 works with VBA.

This issue is really strange... :(
 
D

Doug Robbins - Word MVP

By Right to Left text, I meant, in my case Arabic.

--
Hope this helps

Doug Robbins - Word MVP
Please reply only to the newsgroups unless you wish to avail yourself of my
services on a paid, professional basis.
 
L

Lene Fredborg

(This post may appear more than once due to problems when posting)

I am quite sure that the problem is the one discussed in e.g. this thread:
http://groups.google.com/group/micr.../49bbf1ef19ca11a7?q=word+variable+hotfix+2007

I have experienced the problem myself and found that it was solved by
installing the Hotfix that can be downloaded from here:
http://support.microsoft.com/default.aspx?scid=kb;en-us;970942&sd=rss&spid=11377

I have not noticed any problems after installing the Hotfix.

As Doug said, the problem does not occur when saving in 97-2003 format.

Note that the variables that have already been ruined will not be cured by
installing the Hotfix. They need to be repaired via VBA.


--
Best regards
Lene Fredborg
Microsoft MVP (Word)
DocTools - Denmark
http://www.thedoctools.com
 
D

Doug Robbins - Word MVP

Thanks, Lene. I had forgotten about that.

--
Hope this helps.

Please reply to the newsgroup unless you wish to avail yourself of my
services on a paid consulting basis.

Doug Robbins - Word MVP, originally posted via msnews.microsoft.com
 

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