How to use VBA to revert printer settings after printout to a specific printer

Hi Experts.  I'm hopng somebody can provide me with some guidance.

I am using a printout command and the MODI printer to create a tif document that is then used for processing with an IBM image plus system.  The user click on a button to invoke the printout command, which works quite well.

Problem is, after the command execute, the user's default printer is set to the document image writer.  I've gotten around this by capturing their active printer prior to invoking the printout command, then setting the default printer back to what is was.

Problem I have now is that the "Print to File" option remains selected even for the default printer when it is set back.  I need to set the "Print to File" option to true in the printout command for the document image writer for the document to come across properly, but need it to switch back when I switch the default printer back.

I've tried to set it back after I revert to the previous printer by invoking another printout command and setting the page range to 0,0.  This does the job, but it prints out a blank page (almost blank - two characters in upper right hand corner of the page.

Is there another way to set this back with VBA?

I've attached the relevant code..

Many thanks for any assistance that can be provided.
Dim DefaultPrinterName
    DefaultPrinterName = ActivePrinter
    ActivePrinter = "Microsoft Office Document Image Writer"
    PrintOut False, , , StrFileName, , , , , , , True
    ActivePrinter = DefaultPrinterName
    PrintOut False, , 3, , "0", "0", , , , , False

Open in new window

noclewAsked:
Who is Participating?
 
Joanne M. OrzechConnect With a Mentor Manager, Document Services CenterCommented:
I know in one of our macros...we use an UNDO command to get the printer settings back to what they were.....I don't know if that will work for you but worth a shot I guess :)

' Restore Printer Bins
ActiveDocument.Undo (120)
0
 
Joanne M. OrzechManager, Document Services CenterCommented:
Maybe?
    Application.PrintOut, PrintToFile:=False

Open in new window

0
 
noclewAuthor Commented:
Hi there.

Thanks for the suggestion.  Problem is, this will actually print it out.  I need to suppress the printing while I change the setting back.  I've looked around and gone to this approach, which is close to working, but it printing a page with the characters "IB" in the top left hand corner of a blank page.

Again, any further assistance is greatly appreciated!
    Dim UserDefaultPrinter
    UserDefaultPrinter = ActivePrinter
    ActivePrinter = "Microsoft Office Document Image Writer"
    PrintOut False, , , StrFileName, , , , , , , True
    ActivePrinter = UserDefaultPrinter
    .PrintOut , Range:=4, Pages:="0", PrintToFile:=False

Open in new window

0
Get expert help—faster!

Need expert help—fast? Use the Help Bell for personalized assistance getting answers to your important questions.

 
Joanne M. OrzechManager, Document Services CenterCommented:
hmmm - I see what you mean... never thought of this but then, never had occasion to use it.  I did find somewhat of a workaround that may be helpful but I'll keep looking for now.

http://www.frogmorecs.com/arts/print-to-file.html
0
 
noclewAuthor Commented:
JOrzech, any further thoughts on this?  I'm stumped right now.
0
 
Joanne M. OrzechManager, Document Services CenterCommented:
Sorry - I've been out of town.... but alas, I have no other ideas at the moment. I apologize I couldn't be more helpful to you.

Joanne
0
 
noclewAuthor Commented:
That's OK.  I'm sure I'll call on you again!
0
 
noclewAuthor Commented:
This actually did the job!  Thank you so much!  I've been pulling my hair out for a while with this one.  Again, many thanks!!!
0
 
Joanne M. OrzechManager, Document Services CenterCommented:
Well what do you know!  I'm so glad it worked for you.... it was more or less an afterthought!  :)

Terrific - thank you.... and sorry for the delay.

Joanne Orzech
Word MVP
0
 
noclewAuthor Commented:
Hi Joanne.  Thanks again.

I have another Word question open that perhaps you may be able to assist with.  How can I point you there, if you are interested?
0
 
Joanne M. OrzechManager, Document Services CenterCommented:
But of course I'm interested noclew (funny name :).... just paste a link in this question to your new question and I'll take a look :)

Joanne


0
 
Joanne M. OrzechManager, Document Services CenterCommented:
Oh - I just realized that you've already asked the question... I found it.... I'll take a look :)
0
Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.

All Courses

From novice to tech pro — start learning today.