Using VBA to set PageSetup gives odd error

A

Adrian

I have an Access 2000 system running a word 2000 mail
merge document via OLE. The first run of the
document is ok, the next run I get an invalid value error
when trying to access any of the PageSetup properties and
examining the property in the watch window shows a value
of 999999 ? Can anyone help ?

Code posted below

This is where I pick up the application object reference

oleReport.Verb = acOLEVerbOpen
oleReport.Action = acOLEActivate
Set wordobj = Me.oleReport.Object.Application


Then the pagesetup code is

wordobj.Documents(1).Activate
wordobj.Documents
(1).PageSetup.DifferentFirstPageHeaderFooter = True
wordobj.Documents(1).SectionStart = wdSectionContinuous
wordobj.Documents(1).Repaginate


The exact error message is "value out of range", error
number 4608


Thanks
 
B

Bob S

I have an Access 2000 system running a word 2000 mail
merge document via OLE. The first run of the
document is ok, the next run I get an invalid value error
when trying to access any of the PageSetup properties and
examining the property in the watch window shows a value
of 999999 ? Can anyone help ?

Code posted below

This is where I pick up the application object reference

oleReport.Verb = acOLEVerbOpen
oleReport.Action = acOLEActivate
Set wordobj = Me.oleReport.Object.Application


Then the pagesetup code is

wordobj.Documents(1).Activate
wordobj.Documents
(1).PageSetup.DifferentFirstPageHeaderFooter = True
wordobj.Documents(1).SectionStart = wdSectionContinuous
wordobj.Documents(1).Repaginate


The exact error message is "value out of range", error
number 4608


Thanks


You might try posting this in the VBA group instead. The people who
hang out there know more about VBA code.

You might want to provide a more precise description of what you mean
by "the next run of the document". Do you close and exit between runs?
If not is the second run dealing with the original main document or
the resulting merged document?

You might want to post more complete code. Which section are you
dealing with in the snip above. The first?

Note that a continuous section does not have headers and footers
distinct from the following section, so when you try to set it to
have a different first page header you may not be getting what you
expect.

Bob S
 
Top