"Value out of range" at .RightMargin

R

Rick Charnes

On a Word 2003 macro that's been working fine for a while, I'm all of a
sudden getting an error -

Run-time error '4608'
Value out of range

at the .RightMargin method here:

With ActiveDocument.PageSetup
.RightMargin = InchesToPoints(0.5)
End With

The printer can certainly handle a 1/2" right margin. Any idea what
might cause this? Thanks much.
 
R

Rick Charnes

Minutes later: I see I'm getting that same error no matter what property
I try to apply inside the With ActiveDocument.PageSetup loop. It's
almost as if there's no active document?
 
E

Ed

Hi Rick,

I've seen a problem like this (in our case it was with some code that was
used in a print macro to set the paper trays to print from). The problem only
occurred with certain documents and these all had more than one section. We
can't be sure but we think the documents were created in part by pasting
stuff in from existing documents.

For test purposes I deleted the final section break and the macro would then
run without error.

As a workaround in the macro, I modified the code to avoid using the
ActiveDocument.PageSetup object and, instead, loop through the sections and
use the section-level PageSetup objects. That worked.

Hope this helps.

Ed
 

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