From: LDMueller on
I have a macro which I created by recording the actual steps. This macro
basically takes a 3 page letter, for example and formats the first page to
print from our letterhead tray (tray 1) and all other pages to print from
bond paper tray (tray 3). Our printer is an HP Laserjet 4250.

My problem is this. Sometime's my letter has different margins, etc. (I'm
assuming this is the problem) and because of this I get a Run-time error
'4608: Value out of range error. When I try to Debug it, it will continually
error out on any of the lines under "With ActiveDocument.PageSetup".

I would sincerely appreciate some assistance since I really need to automate
the page setups for documents.



Sub letter1()
'
' letter1 Macro
' Format document to print on Letterhad Paper with Bond for all following
pages
' Macro created 9/27/05 by Leigh Descher Mueller for CWA
'

' Go to top of page
Selection.HomeKey Unit:=wdStory

' Select all
Selection.WholeStory

' Page setup, apply to Whole document,
' First page = Tray 3, Other pages = Tray 3

With ActiveDocument.Styles(wdStyleNormal).Font
If .NameFarEast = .NameAscii Then
.NameAscii = ""
End If
.NameFarEast = ""
End With
With ActiveDocument.PageSetup
.LineNumbering.Active = False
.Orientation = wdOrientPortrait
.TopMargin = InchesToPoints(1)
.BottomMargin = InchesToPoints(1)
.LeftMargin = InchesToPoints(1)
.RightMargin = InchesToPoints(1)
.Gutter = InchesToPoints(0)
.HeaderDistance = InchesToPoints(1)
.FooterDistance = InchesToPoints(1)
.PageWidth = InchesToPoints(8.5)
.PageHeight = InchesToPoints(11)
.FirstPageTray = 260
.OtherPagesTray = 260
.SectionStart = wdSectionNewPage
.OddAndEvenPagesHeaderFooter = False
.DifferentFirstPageHeaderFooter = True
.VerticalAlignment = wdAlignVerticalTop
.SuppressEndnotes = True
.MirrorMargins = False
.TwoPagesOnOne = False
.BookFoldPrinting = False
.BookFoldRevPrinting = False
.BookFoldPrintingSheets = 1
.GutterPos = wdGutterPosLeft
End With

'Go Home
Selection.HomeKey Unit:=wdStory

' F8, go to Page 2
Selection.Extend
Selection.GoTo What:=wdGoToPage, Which:=wdGoToNext, Name:="2"
Selection.Find.ClearFormatting
With Selection.Find
.Text = ""
.Replacement.Text = ""
.Forward = True
.Wrap = wdFindContinue
.Format = False
.MatchCase = False
.MatchWholeWord = False
.MatchWildcards = False
.MatchSoundsLike = False
.MatchAllWordForms = False
End With

' Page setup, Apply to Selected sections,
' First page = Tray 1, Other pages = Tray 3
With Selection.PageSetup
.LineNumbering.Active = False
.Orientation = wdOrientPortrait
.TopMargin = InchesToPoints(1)
.BottomMargin = InchesToPoints(1)
.LeftMargin = InchesToPoints(1)
.RightMargin = InchesToPoints(1)
.Gutter = InchesToPoints(0)
.HeaderDistance = InchesToPoints(1)
.FooterDistance = InchesToPoints(1)
.PageWidth = InchesToPoints(8.5)
.PageHeight = InchesToPoints(11)
.FirstPageTray = 262
.OtherPagesTray = 260
.SectionStart = wdSectionNewPage
.OddAndEvenPagesHeaderFooter = False
.DifferentFirstPageHeaderFooter = True
.VerticalAlignment = wdAlignVerticalTop
.SuppressEndnotes = True
.MirrorMargins = False
.TwoPagesOnOne = False
.BookFoldPrinting = False
.BookFoldRevPrinting = False
.BookFoldPrintingSheets = 1
.GutterPos = wdGutterPosLeft
End With

'Go Home
Selection.HomeKey Unit:=wdStory
End Sub

From: Casey Mac on
I have the exact same error on my code: I hope some one can help. im using
word 2003

ActiveDocument.PageSetup.DifferentFirstPageHeaderFooter = True
Set oRng = ActiveDocument.Sections(1).Footers(wdHeaderFooterPrimary).Range
oRng.ParagraphFormat.Alignment = wdAlignParagraphCenter
NormalTemplate.AutoTextEntries("Page X of Y").Insert Where:=oRng,
RichText:=True


From: Jean-Guy Marcil on
Casey Mac was telling us:
Casey Mac nous racontait que :

> I have the exact same error on my code: I hope some one can help. im
> using word 2003
>
> ActiveDocument.PageSetup.DifferentFirstPageHeaderFooter = True
> Set oRng =
> ActiveDocument.Sections(1).Footers(wdHeaderFooterPrimary).Range
> oRng.ParagraphFormat.Alignment = wdAlignParagraphCenter
> NormalTemplate.AutoTextEntries("Page X of Y").Insert Where:=oRng,
> RichText:=True

Your code ran fine as is (Word 2003) on my machine.
By the way, you may be experiencing the same error message as the OP, but it
is definitely a different problem. It would be better to start a new
thread...

--
Salut!
_______________________________________
Jean-Guy Marcil - Word MVP
jmarcilREMOVE(a)CAPSsympatico.caTHISTOO
Word MVP site: http://www.word.mvps.org


From: Jean-Guy Marcil on
LDMueller was telling us:
LDMueller nous racontait que :

> I have a macro which I created by recording the actual steps. This
> macro basically takes a 3 page letter, for example and formats the
> first page to print from our letterhead tray (tray 1) and all other
> pages to print from bond paper tray (tray 3). Our printer is an HP
> Laserjet 4250.
>
> My problem is this. Sometime's my letter has different margins, etc.
> (I'm assuming this is the problem) and because of this I get a
> Run-time error '4608: Value out of range error. When I try to Debug
> it, it will continually error out on any of the lines under "With
> ActiveDocument.PageSetup".
>
> I would sincerely appreciate some assistance since I really need to
> automate the page setups for documents.
>

First, I would suggest that you clean up your macro...
See
http://word.mvps.org/faqs/macrosvba/ModifyRecordedMacro.htm


--
Salut!
_______________________________________
Jean-Guy Marcil - Word MVP
jmarcilREMOVE(a)CAPSsympatico.caTHISTOO
Word MVP site: http://www.word.mvps.org


From: LDMueller on
Thank your for your response. This information was very helpful, however, I
had cleaned it up initally and when it didn't work, I put everything back in.

The following is my updated code, however it still doesn't work. We have
Word 2003 and our printer is an HP Laserjet 4250.

Selection.WholeStory
With ActiveDocument.PageSetup
.FirstPageTray = 262
.OtherPagesTray = 260
End With

Thanks!

"Jean-Guy Marcil" wrote:

> LDMueller was telling us:
> LDMueller nous racontait que :
>
> > I have a macro which I created by recording the actual steps. This
> > macro basically takes a 3 page letter, for example and formats the
> > first page to print from our letterhead tray (tray 1) and all other
> > pages to print from bond paper tray (tray 3). Our printer is an HP
> > Laserjet 4250.
> >
> > My problem is this. Sometime's my letter has different margins, etc.
> > (I'm assuming this is the problem) and because of this I get a
> > Run-time error '4608: Value out of range error. When I try to Debug
> > it, it will continually error out on any of the lines under "With
> > ActiveDocument.PageSetup".
> >
> > I would sincerely appreciate some assistance since I really need to
> > automate the page setups for documents.
> >
>
> First, I would suggest that you clean up your macro...
> See
> http://word.mvps.org/faqs/macrosvba/ModifyRecordedMacro.htm
>
>
> --
> Salut!
> _______________________________________
> Jean-Guy Marcil - Word MVP
> jmarcilREMOVE(a)CAPSsympatico.caTHISTOO
> Word MVP site: http://www.word.mvps.org
>
>
>