Solved

Debug Error/ print current page/ Background printing

Posted on 2004-09-07
6
781 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
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 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
Get HTML5 Certified

Want to be a web developer? You'll need to know HTML. Prepare for HTML5 certification by enrolling in July's Course of the Month! It's free for Premium Members, Team Accounts, and Qualified Experts.

 

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

On Demand Webinar - Networking for the Cloud Era

This webinar discusses:
-Common barriers companies experience when moving to the cloud
-How SD-WAN changes the way we look at networks
-Best practices customers should employ moving forward with cloud migration
-What happens behind the scenes of SteelConnect’s one-click button

Question has a verified solution.

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

Do you ever need to create a 20 page Word document for some testing purpose? Are you tired of copying & pasting old boring "lorem ipsum" text over and over again, increasing font size and line space in order to make the document 20+ pages long? Look…
It is often necessary in this forum and others to illustrate Word fields as text with the field delimiters replaced with the curly brackets that the delimiters resemble when field codes are being displayed on the document. This means that the text c…
In this video, we show how to convert an image-only PDF file into a PDF Searchable Image file, that is, a file with both the image (typically from scanning) and text, which is created in an automated fashion with Optical Character Recognition (OCR) …
This video shows where to find templates, what they are used for, and how to create and save a custom template using Microsoft Word.

627 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