Go Premium for a chance to win a PS4. Enter to Win

x
?
Solved

Debug Error/ print current page/ Background printing

Posted on 2004-09-07
6
Medium Priority
?
786 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
[Webinar] Cloud and Mobile-First Strategy

Maybe you’ve fully adopted the cloud since the beginning. Or maybe you started with on-prem resources but are pursuing a “cloud and mobile first” strategy. Getting to that end state has its challenges. Discover how to build out a 100% cloud and mobile IT strategy in this webinar.

 

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 1200 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

How to Use the Help Bell

Need to boost the visibility of your question for solutions? Use the Experts Exchange Help Bell to confirm priority levels and contact subject-matter experts for question attention.  Check out this how-to article for more information.

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…
Nice table. Huge mess. Maybe this was something you created way back before you figured out tabs or a document you received from someone else. Either way, using the spacebar to separate the columns resulted in a mess. Trying to convert text to t…
This video walks the viewer through the process of creating a watermark for their document, customizing it, and saving it for viewing/printing needs.
This Micro Tutorial well show you how to find and replace special characters in Microsoft Word. This is similar to carriage returns to convert columns of values from Microsoft Excel into comma separated lists.

971 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