Solved

Debug Error/ print current page/ Background printing

Posted on 2004-09-07
6
778 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
Free Tool: Postgres Monitoring System

A PHP and Perl based system to collect and display usage statistics from PostgreSQL databases.

One of a set of tools we are providing to everyone as a way of saying thank you for being a part of the community.

 

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

Free Tool: Site Down Detector

Helpful to verify reports of your own downtime, or to double check a downed website you are trying to access.

One of a set of tools we are providing to everyone as a way of saying thank you for being a part of the community.

Question has a verified solution.

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

Suggested Solutions

The Selection object is designed for user interaction. It has a Range property, so it can be used in most places that a Range object can. Recorded macros must use the Selection because they are simply copying what the user is doing. A Range prope…
Introduction This tutorial provides instructions on how to properly format your Word document using the inbuilt tools provided. The benefits of using these tools means your documents are more accessible and easily portable to other applications an…
This video teaches the viewer how to align pictures around text while keeping the text properly aligned in the document.
This video walks the viewer through the process of creating an MLA formatted document, as well as a bibliography with citations.

828 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