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!!!!!!!!!!!
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!!!!!!!!!!!