• Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 792
  • Last Modified:

Debug Error/ print current page/ Background printing

I am trying to make a button to print the current page, though many of the pages are outside of the printable page area so i want to get rid of the dialog "outside of the...do you wish to continue..." box. I tried to piece together some code but i get a 424 object required error on the last line. Can anyone help? Here is what i have.

Sub PrintCurr()

    Application.DisplayAlerts = wdAlertsNone
    ActiveDocument.PrintOut Background:=False, Range:=wdPrintCurrentPage
   ¬†Application.DisplayAlerts = wdAlertsAll
   
End Sub

Thanks
Brad
0
BradDuns
Asked:
BradDuns
  • 3
  • 2
1 Solution
 
SQL_StuCommented:
Have u tried commenting out the 2 displayalerts lines?  Perhaps the problem lies in your remaining line of code?  Have u tried the printout line just using defaults?

Otherwise, I can't see a lot wrong with the above.
0
 
BradDunsAuthor Commented:
it prints if i get rid of the display alerts but i still see the dialog box, and it's the same when i use defaults on the print out line.
0
 
SQL_StuCommented:
I'm at a loss to help as I've copy/pasted your code onto my PC and it works fine.

Where is your button located?  Perhaps Word cannot determine what the ActiveDocument is?
0
Keep up with what's happening at Experts Exchange!

Sign up to receive Decoded, a new monthly digest with product updates, feature release info, continuing education opportunities, and more.

 
BradDunsAuthor Commented:
thanks for the help
the button is in one of my custom toolbars. the macro is located in a template which my document is built from. i tried to move the macro into the actual doc instead of the template but the same thing happened. when i run the debug the last line "Application.DisplayAlerts = wdAlertsAll" is highlighted.  I am also running word 2004 on Mac i don't know if that matters.
0
 
Kelly_in_Los_AngelesCommented:
Just a couple of totally random ideas to try....

since the value of the "wdAlertsAll" constant is -1, what happens if you try:

Application.DisplayAlerts = -1

Also, you should be able to leave off the "Application" part, so why not try:

Sub PrintCurr()

DisplayAlerts = wdAlertsNone
ActiveDocument.PrintOut Background:=False, Range:=wdPrintCurrentPage
DisplayAlerts = wdAlertsAll
   
End Sub

Although, I must say that I have also tested your original code, and like SQL_Stu, it worked perfectly on my machine.  And I did test it on a document with margins out of range.
0
 
BradDunsAuthor Commented:
The code withou the application worked great.

thank you
0

Featured Post

Receive 1:1 tech help

Solve your biggest tech problems alongside global tech experts with 1:1 help.

  • 3
  • 2
Tackle projects and never again get stuck behind a technical roadblock.
Join Now