recorded macro gives runtime error when trying to run

R

Robert L. Sullivan

I recorded the following macro to change pagesetup entries on the entire
document. When I record it, it runs fine. When I try to execute it on a
document with an attached template (not normal.dot) I get "Runtime error
4608, value out of range). I can, however, run the macro on a document
created with the normal.dot template. Any ideas what this might be?

Thanks in advance.

Here is the macro as recorded....

Sub Macro11()
'
' Macro11 Macro
' Macro recorded 10/26/2006 by sullivanr
'
With ActiveDocument.PageSetup
.LineNumbering.Active = False
.Orientation = wdOrientPortrait
.LeftMargin = InchesToPoints(0.5)
.RightMargin = InchesToPoints(0.5)
.Gutter = InchesToPoints(0)
.HeaderDistance = InchesToPoints(0.5)
.PageWidth = InchesToPoints(8.5)
.PageHeight = InchesToPoints(11)
.FirstPageTray = wdPrinterDefaultBin
.OtherPagesTray = wdPrinterDefaultBin
.SectionStart = wdSectionNewPage
.OddAndEvenPagesHeaderFooter = False
.DifferentFirstPageHeaderFooter = True
.VerticalAlignment = wdAlignVerticalTop
.SuppressEndnotes = False
.MirrorMargins = False
.TwoPagesOnOne = False
.GutterPos = wdGutterPosLeft
End With
End Sub
 
B

Beth Melton

Which line of your macro is causing the error? When you encounter the
error click the Debug button and the line causing the error will be
highlighted in yellow.

Also, which Page Setup options do you want to change? When you record
a macro every option is included and more often than not there's only
a couple options you want to change, such as the page margins. What
you want to do is keep only the settings you want to change and delete
all of the others.

Please post all follow-up questions to the newsgroup. Requests for
assistance by email can not be acknowledged.

~~~~~~~~~~~~~~~
Beth Melton
Microsoft Office MVP

Office 2007 Preview Site:
http://www.microsoft.com/office/preview/default.mspx
Office 2007 Community Articles/Tutorials:
http://www.microsoft.com/office/preview/community/article_archive.mspx

TechTrax eZine: http://mousetrax.com/techtrax/
MVP FAQ site: http://mvps.org/
 
R

Robert L. Sullivan

Beth,

I tried changing a few of the properties (using set next statement). I got
the same error on each property I tested. I am aware of the ability to change
only the properties I needed. I ran the previous test case (i.e. I recorded
the marco) when the 2 I wanted to change generated the error. I got around
the error by looping through the sections in my macro, so the error is now a
moot point. I'm modifying code in an existing template, which can be akin to
remodeling an old house :).

Regards,
Bob
 

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