PageSetup from VBA gives invalid value error

A

Adrian

Hi all

I have an Access 2000 system running a word 2000 mail
merge document via OLE. If I don't have anything open in
word, alls fine. If I have Word open 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 ?

Thanks
Adrian
 
C

Cindy M -WordMVP-

Hi Adrian,
I have an Access 2000 system running a word 2000 mail
merge document via OLE. If I don't have anything open in
word, alls fine. If I have Word open 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 ?
Not without knowing more. Please copy/paste the relevant
portion of your code (including where you declare the app
variable, set it, and release it) into your reply.

Please also tell us the *exact* error message you're
getting.

Cindy Meister
INTER-Solutions, Switzerland
http://homepage.swissonline.ch/cindymeister (last update Sep
30 2003)
http://www.mvps.org/word

This reply is posted in the Newsgroup; please post any
follow question or reply in the newsgroup and not by e-mail
:)
 
B

Bob S

I have an Access 2000 system running a word 2000 mail
merge document via OLE. If I don't have anything open in
word, alls fine. If I have Word open 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 ?

No code posted, so we'll have to try telepathic debugging...

My crystal ball says that your code is looking at the page setup
parameters of a "selection", that your code does not set the selection
object before using it, and that your code leaves the selection object
covering multiple "sections" (e.g. the whole merged document) when it
finishes the merge.

If that isn't it, you'll either have to post some code or find a
better class of fortune teller.

Bob S
 
A

Adrian

Sorry guys, heres the relevant portions of code

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
 
C

Cindy M -WordMVP-

Hi Adrian,
Sorry guys, heres the relevant portions of code
I'm still missing where you RELEASE the Word application
and its object variables...

Note: this probably has nothing to do with the error
message, but it would be more "efficient" if you'd also use
an object variable instead of Documents(1) to work with the
document. Example:
Set doc = wordobj.Documents(1)

Cindy Meister
INTER-Solutions, Switzerland
http://homepage.swissonline.ch/cindymeister (last update
Sep 30 2003)
http://www.mvps.org/word

This reply is posted in the Newsgroup; please post any
follow question or reply in the newsgroup and not by e-mail
:)
 

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