Run-time error '4608'

  • Thread starter M. DiCanio via OfficeKB.com
  • Start date
M

M. DiCanio via OfficeKB.com

Hi,

I am frustrated. I keep getting the error Run-time error '4608' Valule
out of Range.

Here are the details. This error only occurs in a specific Word 2003
document. It happens when I click either one of two buttons on my toolbar
that are linked to a macro that sends the document to either the upper or
lower printer tray. Here is the VBA code for the macro:

Option Explicit
------------------------------------------
Sub UpperTray()

Dim OriginalFirstPageSetting As Long
Dim OriginalOtherPagesSetting As Long
Dim FirstPageTray As Long
Dim OtherPagesTray As Long
Dim wdPrinterMiddleBin As Long

With ActiveDocument.PageSetup

OriginalFirstPageSetting = .FirstPageTray
OriginalOtherPagesSetting = .OtherPagesTray

.FirstPageTray = wdPrinterMiddleBin
.OtherPagesTray = wdPrinterMiddleBin

ActiveDocument.PrintOut

.FirstPageTray = OriginalFirstPageSetting
.OtherPagesTray = OriginalOtherPagesSetting

End With


End Sub
---------------------------------------------------
Sub LowerTray()

Dim OriginalFirstPageSetting As Long
Dim OriginalOtherPagesSetting As Long
Dim FirstPageTray As Long
Dim OtherPagesTray As Long

With ActiveDocument.PageSetup

OriginalFirstPageSetting = .FirstPageTray
OriginalOtherPagesSetting = .OtherPagesTray

.FirstPageTray = wdPrinterLowerBin
.OtherPagesTray = wdPrinterLowerBin

ActiveDocument.PrintOut

.FirstPageTray = OriginalFirstPageSetting
.OtherPagesTray = OriginalOtherPagesSetting
End With
End Sub

Can anyone help? I am not great at programming but will do my best to
respond to any questions you need answered to help solve the problem.

Thanks.
 
N

Neil Shepherd via OfficeKB.com

I also got this error for setting page trays with activedocument.pagesetup
Not a problem with Word 97 however.

I used the built-in dialog to do the job and it works.

Try



dim lngFirstPage as long
dim lngOtherPages as long

lngFirstPage = 1
lngOtherPages = 2

With Dialogs(wdDialogFilePageSetup)
.FirstPage = lngFirstPage
.OtherPages = lngOtherPages
.Execute
End With
 
N

Neil Shepherd via OfficeKB.com

Here is how I would write one of your sub provided I understood it properly
.....

Sub LowerTray()

Dim OriginalFirstPageSetting As Long
Dim OriginalOtherPagesSetting As Long

' I dont know why you need these two declarations
Dim FirstPageTray As Long
Dim OtherPagesTray As Long

' save the current settings
With Dialogs(wdDialogFilePageSetup)
OriginalFirstPageSetting = .FirstPage
OriginalOtherPagesSetting = .OtherPages
End With

' change document settings to default
With Dialogs(wdDialogFilePageSetup)
.FirstPage = wdPrinterLowerBin
.OtherPages = wdPrinterLowerBin
.Execute
End With

' print the doco
ActiveDocument.PrintOut

' restore the original settings
With Dialogs(wdDialogFilePageSetup)
FirstPage = OriginalFirstPageSetting
.OtherPages = OriginalOtherPagesSetting
.Execute
End With

End Sub


I have run it through the the debugger and the Dialog changes the paper
tray settings OK as the code runs.

Good luck anyway.
 
M

Mike DiCanio

Neil,

This seems to have eliminated the error and the tray buttons
are working fine but I have to test it with the user.

I will post the result when we confirm success.

Thanks for responding and helping with this.

Mike
 
B

Bodiller

Maybe somebody can help me too!

I have the following macro to print on letterhead and then on blank paper
with a header, then I delete the header and close. It works with all my
templates except for one and gives me above error!!!???

Sub UdskrivAlt()
'
' UdskrivAlt Makro
' Udskriver Original, SAGS-KOPI
'
If ActiveWindow.View.SplitSpecial = wdPaneNone Then
ActiveWindow.ActivePane.View.Type = wdPageView
Else
ActiveWindow.View.Type = wdPageView
End If
With ActiveDocument.PageSetup
.FirstPageTray = wdPrinterMiddleBin
.OtherPagesTray = wdPrinterMiddleBin
End With
ActiveDocument.PrintOut
With ActiveDocument.PageSetup
.FirstPageTray = wdPrinterDefaultBin
.OtherPagesTray = wdPrinterDefaultBin
End With
ActiveWindow.ActivePane.View.SeekView = wdSeekCurrentPageHeader
Selection.Font.Bold = wdToggle
Selection.ParagraphFormat.Alignment = wdAlignParagraphCenter
Selection.TypeText Text:="SAGS-KOPI"
ActiveWindow.ActivePane.View.SeekView = wdSeekMainDocument
ActiveDocument.PrintOut
ActiveWindow.ActivePane.View.SeekView = wdSeekCurrentPageHeader
Selection.Delete Unit:=wdCharacter, Count:=1
Selection.Delete Unit:=wdCharacter, Count:=1
Selection.Delete Unit:=wdCharacter, Count:=1
Selection.Delete Unit:=wdCharacter, Count:=1
Selection.Delete Unit:=wdCharacter, Count:=1
Selection.Delete Unit:=wdCharacter, Count:=1
Selection.Delete Unit:=wdCharacter, Count:=1
Selection.Delete Unit:=wdCharacter, Count:=1
Selection.Delete Unit:=wdCharacter, Count:=1
Selection.Delete Unit:=wdCharacter, Count:=1
ActiveWindow.ActivePane.View.SeekView = wdSeekMainDocument
End Sub


Can anybody help me please!!! I have seen Neil Shepherd's suggestions but I
do not know where to insert!! I x my fingers!!

Regards
Bodiller

"Mike DiCanio" skrev:
 
D

Doug Robbins

And what line of code is highlighted when you click on debug?

--
Hope this helps.

Please reply to the newsgroup unless you wish to avail yourself of my
services on a paid consulting basis.

Doug Robbins - Word MVP
 
B

Bodiller

Hi,
ALWAYS the first line after "With ActiveDocument.PageSetup"

Can you possibly help me!!
Regards
Bodiller

"Doug Robbins" skrev:
 
D

Doug Robbins

The first or the second one?

I'm guessing it is the second and it is falling over because Word is still
printing the document. If that is the case, you should be able to overcome
it by using

ActiveDocument.PrintOut Background = False

--
Hope this helps.

Please reply to the newsgroup unless you wish to avail yourself of my
services on a paid consulting basis.

Doug Robbins - Word MVP
Bodiller said:
Hi,
ALWAYS the first line after "With ActiveDocument.PageSetup"

Can you possibly help me!!
Regards
Bodiller

"Doug Robbins" skrev:
 
B

Bodiller

Dear Doug,
When I saw your suggestions I was soooo happy!

Well, it always stops at the FIRST one!

I have tried to insert as per your suggestion - first at the first
ACTIVEDOCUMENT.PRINTOUT - did not work. Then added to the second - but
that did not help either!!

Any other suggestions???????

Regards
Bodiller

"Doug Robbins" skrev:
 

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