Link to home
Start Free TrialLog in
Avatar of noclew
noclew

asked on

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

Avatar of Joanne M. Orzech
Joanne M. Orzech
Flag of United States of America image

Maybe?
    Application.PrintOut, PrintToFile:=False

Open in new window

Avatar of noclew
noclew

ASKER

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

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
Avatar of noclew

ASKER

JOrzech, any further thoughts on this?  I'm stumped right now.
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
Avatar of noclew

ASKER

That's OK.  I'm sure I'll call on you again!
ASKER CERTIFIED SOLUTION
Avatar of Joanne M. Orzech
Joanne M. Orzech
Flag of United States of America image

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
Avatar of noclew

ASKER

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!!!
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
Avatar of noclew

ASKER

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


Oh - I just realized that you've already asked the question... I found it.... I'll take a look :)