Link to home
Start Free TrialLog in
Avatar of BradDuns
BradDuns

asked on

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
Avatar of SQL_Stu
SQL_Stu
Flag of United Kingdom of Great Britain and Northern Ireland image

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.
Avatar of BradDuns
BradDuns

ASKER

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.
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?
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.
ASKER CERTIFIED SOLUTION
Avatar of Kelly_in_Los_Angeles
Kelly_in_Los_Angeles

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
The code withou the application worked great.

thank you