Solved

Debug Error/ print current page/ Background printing

Posted on 2004-09-07
6
776 Views
Last Modified: 2008-01-09
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
Comment
Question by:BradDuns
  • 3
  • 2
6 Comments
 
LVL 7

Expert Comment

by:SQL_Stu
ID: 11997858
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
 

Author Comment

by:BradDuns
ID: 11998122
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
 
LVL 7

Expert Comment

by:SQL_Stu
ID: 11998169
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
Is Your Active Directory as Secure as You Think?

More than 75% of all records are compromised because of the loss or theft of a privileged credential. Experts have been exploring Active Directory infrastructure to identify key threats and establish best practices for keeping data safe. Attend this month’s webinar to learn more.

 

Author Comment

by:BradDuns
ID: 11998572
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
 
LVL 1

Accepted Solution

by:
Kelly_in_Los_Angeles earned 300 total points
ID: 11999335
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
 

Author Comment

by:BradDuns
ID: 11999815
The code withou the application worked great.

thank you
0

Featured Post

Is Your Active Directory as Secure as You Think?

More than 75% of all records are compromised because of the loss or theft of a privileged credential. Experts have been exploring Active Directory infrastructure to identify key threats and establish best practices for keeping data safe. Attend this month’s webinar to learn more.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

I'm writing to share my clumsy experience in using this elegant tool so you can avoid every stupid mistake I made. (I leave it to the authorities to decide if this deserves a place in the Knowledge archives.)  Now that I am on the other side of my l…
Microsoft Word is a program we have all encountered at some point, but very few of us have dug deep into its full scope of features, let alone customized it to suit our needs. Luckily making the ribbon (aka toolbar, first introduced in Word 2007) wo…
Learn how to make your own table of contents in Microsoft Word using paragraph styles and the automatic table of contents tool. We'll be using the paragraph styles in Word’s Home toolbar to help you create a table of contents. Type out your initial …
In a previous video Micro Tutorial here at Experts Exchange (http://www.experts-exchange.com/videos/1358/How-to-get-a-free-trial-of-Office-365-with-the-Office-2016-desktop-applications.html), I explained how to get a free, one-month trial of Office …

867 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question

Need Help in Real-Time?

Connect with top rated Experts

24 Experts available now in Live!

Get 1:1 Help Now