Home | Contact Us | FAQ | Search & Site Map | Link to Us
Sign In | Join | Other 45 Sites in Network
Home
DiscussionsAccessExcelInfoPathOutlookPowerPointPublisherWord
DirectoryUser Groups
Related Topics
Outlook ExpressInternet ExplorerWindowsMS Server ProductsMore Topics ...

MS Office Forum / Word / Programming / June 2005

Tip: Looking for answers? Try searching our database.

Run-time error '4608'

Thread view: 
Enable EMail Alerts  Start New Thread
Thread rating: 
M. DiCanio - 08 Mar 2005 16:07 GMT
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.
Neil Shepherd - 17 Mar 2005 04:44 GMT
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
Mike DiCanio - 22 Mar 2005 16:55 GMT
Neil,

Thanks for the reply.

Would I replace my VBA code with yours?

Mike

> I also got this error for setting page trays with activedocument.pagesetup
> Not a problem with Word 97 however.
[quoted text clipped - 15 lines]
>     .Execute
>  End With
Neil Shepherd - 31 Mar 2005 08:09 GMT
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.
Mike DiCanio - 20 Apr 2005 16:30 GMT
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

> Here is how I would write one of your sub provided I understood it properly
> .....
[quoted text clipped - 37 lines]
>
> Good luck anyway.
Bodiller - 27 Jun 2005 12:17 GMT
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:

> Neil,
>
[quoted text clipped - 48 lines]
> >
> > Good luck anyway.
Doug Robbins - 28 Jun 2005 22:25 GMT
And what line of code is highlighted when you click on debug?

Signature

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

> Maybe somebody can help me too!
>
[quoted text clipped - 103 lines]
>> >
>> > Good luck anyway.
Bodiller - 29 Jun 2005 08:34 GMT
Hi,
ALWAYS the first line after "With ActiveDocument.PageSetup"

Can you  possibly help me!!
Regards
Bodiller

"Doug Robbins" skrev:

> And what line of code is highlighted when you click on debug?
>
[quoted text clipped - 105 lines]
> >> >
> >> > Good luck anyway.
Doug Robbins - 29 Jun 2005 21:19 GMT
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

Signature

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

> Hi,
> ALWAYS the first line after "With ActiveDocument.PageSetup"
[quoted text clipped - 118 lines]
>> >> >
>> >> > Good luck anyway.
Bodiller - 30 Jun 2005 16:26 GMT
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:

> The first or the second one?
>
[quoted text clipped - 126 lines]
> >> >> >
> >> >> > Good luck anyway.

Rate this thread:






 
Sign In
Join
My Latest Posts
My Monitored Threads
My Blog
My Photo Gallery
My Profile
My Homepage

Start New Thread
Enable EMail Alerts
Rate this Thread



©2008 Advenet LLC   Privacy Policy - Terms of Use
This website includes both content owned or controlled by Advenet as well as content owned or controlled by third parties.