A
Aristotelis E. Charalampakis
I am new to VBA.
I am using the following code within VB 6.0 to print "Page XXX of YYY
- Copyright ...." in the footer of two documents.
Dim rngFooter As Object 'if i define it as Range, nothing
happens
Set rngFooter =
myWord.ActiveDocument.Sections(1).Footers(wdHeaderFooterPrimary).Range
rngFooter.Text = "Page "
rngFooter.Collapse wdCollapseEnd
rngFooter.Move wdCharacter, 1
rngFooter.Fields.Add rngFooter, wdFieldPage
rngFooter.Collapse wdCollapseEnd
rngFooter.Move wdCharacter, 1
rngFooter.Text = " of "
rngFooter.Collapse wdCollapseEnd
rngFooter.Move wdCharacter, 1
rngFooter.Fields.Add rngFooter, wdFieldNumPages
rngFooter.Collapse wdCollapseEnd
rngFooter.Move wdCharacter, 1
rngFooter.Text = " - Copyright ...."
Strangely, this works as expected in one case and fails in the other.
In the failed case, the footer becomes "Page XXXYYY" with no space in
between. If the document has 23 pages, the footers become "Page 123",
"Page 223", etc.
Any ideas?
TIA
Aristotelis
I am using the following code within VB 6.0 to print "Page XXX of YYY
- Copyright ...." in the footer of two documents.
Dim rngFooter As Object 'if i define it as Range, nothing
happens
Set rngFooter =
myWord.ActiveDocument.Sections(1).Footers(wdHeaderFooterPrimary).Range
rngFooter.Text = "Page "
rngFooter.Collapse wdCollapseEnd
rngFooter.Move wdCharacter, 1
rngFooter.Fields.Add rngFooter, wdFieldPage
rngFooter.Collapse wdCollapseEnd
rngFooter.Move wdCharacter, 1
rngFooter.Text = " of "
rngFooter.Collapse wdCollapseEnd
rngFooter.Move wdCharacter, 1
rngFooter.Fields.Add rngFooter, wdFieldNumPages
rngFooter.Collapse wdCollapseEnd
rngFooter.Move wdCharacter, 1
rngFooter.Text = " - Copyright ...."
Strangely, this works as expected in one case and fails in the other.
In the failed case, the footer becomes "Page XXXYYY" with no space in
between. If the document has 23 pages, the footers become "Page 123",
"Page 223", etc.
Any ideas?
TIA
Aristotelis