Prevent print message from displaying

J

JoAnn

I'm using PrintOut to print the document's current page to a file but don't
know how to prevent the "printing ..." message from appearing on the screen.

Is there some code I can use to suppress the message? I'm using Word 2003.
Thanks,
 
J

Jean-Guy Marcil

JoAnn was telling us:
JoAnn nous racontait que :
I'm using PrintOut to print the document's current page to a file but
don't know how to prevent the "printing ..." message from appearing
on the screen.

Is there some code I can use to suppress the message? I'm using Word
2003. Thanks,

Have you try making sure that printing to background was on?

Try this:
'_______________________________________
Dim BackGroundPrint As Boolean

'Save the current Print to background state
BackGroundPrint = Options.PrintBackground

'Make sure it is set to print in the background
If Not BackGroundPrint Then
Options.PrintBackground = True
End If

ActiveDocument.PrintOut

'Restore the Print to background state, if necessary
If Not BackGroundPrint Then
Options.PrintBackground = BackGroundPrint
End If
'_______________________________________
--
Salut!
_______________________________________
Jean-Guy Marcil - Word MVP
(e-mail address removed)
Word MVP site: http://www.word.mvps.org
 
J

JoAnn

Thank you for the suggestion but it didn't help. I still see a a brief flash
of the print message but it is then quickly replaced by an error message
saying "permission denied" when my code tries to "kill" the dummy file I
printed. Not being able to delete my dummy file is a new development since
adding your code. Your suggestion makes sense -- I don't understand why it
doesn't work & why it created a new problem.

My code is set up as Document_New and Document_Open events in ThisDocument.
I tried using Auto_Open and Auto_New (which doesn't seem to show the print
message when I print to file) but I found I couldn't delete the file that. So
I went back to using the events in ThisDocument.

Maybe I 'm going about this wrong ... all I'm trying to do is print the
current page to a file (to clear up/prevent an intermittent problem where all
of my page xrefs display "3" or "4"), not show a print message to the user
while printing & then delete the dummy file I created. Since it will be used
on different systems, it needs to be able to find the file wherever it was
created & delete it.

To print, I am using PrintOut with the PrintToFile & OutputFilename options
set (added your code to set it to background print & then turn it off when
done). To name the dummy file, I'm using a variable built on the
Options.DefaultFilePath(wdDocumentsPath) & the hard-coded file name
"dummy_file.prn". To delete the file, I'm using Kill with the variable that
contains the full path & filename.

Any suggestions?

Thank you,
JoAnn
 
J

Jonathan West

Setting Background:=True in the Printout method means that your macro goes
on to the next line before the creation of the print file is completed.

If you want to delete the print file or otherwise process it, you'll need to
stop & wait a while, and check whether the printing has completed. Simply
going into a loop will not do the needful - all the processor power till be
taken up by the loop leaving nothing for the printing.

To get round this, use the OnTime command to run a macro in a few seconds'
time. The macro should check the value of the BackgroundPrintingStatus
property. If it is greater than zero, the file is still printing, so you use
OnTime to run the same macro again in a few more seconds. Once
BackgroundPrintingStatus is zero then you can continue with your processing

--
Regards
Jonathan West - Word MVP
www.intelligentdocuments.co.uk
Please reply to the newsgroup
Keep your VBA code safe, sign the ClassicVB petition www.classicvb.org
 
J

JoAnn

Help!
I've been researching your suggestion to use OnTime & create a macro to
check the status but have gotten quite confused about how to go about it (do
loops, if statements, etc.) ... sorry I'm not a programmer and sometimes I
know just enough about VBA coding to get myself into trouble!!

Please help. I understand about adding the statement for OnTime --- i.e.
Application.OnTime when:= Now + TimeValue("00:00:08") Name:=
"Check_Print_Status"

As for the Check_Print_Status macro ... I know I must create a var (as
long?) to store the status (i.e. pstatus =
Application.BackgroundPrintingStatus) then if the status is >0 somehow run
Ontime again until it clears. But not sure how I should be doing this -- do
I use a do loop or if statement, etc. nesting another OnTime statement ?? I'm
confused about what code to use to ensure it repeats as often as needed
without causing an endless loop. My few attempts at different things seemed
to cause an endless loop so I dumped the code figuring I'm way off base with
the basics.

And where do I need to store the check status macro if I'm using
ThisDocument (Document New event) vs. using AutoNew? This is used by many
users on different PCs when attached to a specific template so putting it in
normal.dot isn't an option. I was hoping to have it run when they attach to a
specific template (or if using AutoOpen/AutoNew, whenever they open or create
a new doc built off the template).

Thanks for your help!
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top