[Last Call] Learn how to a build a cloud-first strategyRegister Now

x
?
Solved

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

Posted on 2009-02-19
12
Medium Priority
?
396 Views
Last Modified: 2012-05-06
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

0
Comment
Question by:noclew
  • 7
  • 5
12 Comments
 
LVL 37

Expert Comment

by:Joanne M. Orzech
ID: 23692705
Maybe?
    Application.PrintOut, PrintToFile:=False

Open in new window

0
 

Author Comment

by:noclew
ID: 23693280
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
 
LVL 37

Expert Comment

by:Joanne M. Orzech
ID: 23694247
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
VIDEO: THE CONCERTO CLOUD FOR HEALTHCARE

Modern healthcare requires a modern cloud. View this brief video to understand how the Concerto Cloud for Healthcare can help your organization.

 

Author Comment

by:noclew
ID: 23775421
JOrzech, any further thoughts on this?  I'm stumped right now.
0
 
LVL 37

Expert Comment

by:Joanne M. Orzech
ID: 23837169
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
 

Author Comment

by:noclew
ID: 23841628
That's OK.  I'm sure I'll call on you again!
0
 
LVL 37

Accepted Solution

by:
Joanne M. Orzech earned 2000 total points
ID: 23846150
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
 

Author Closing Comment

by:noclew
ID: 31548911
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
 
LVL 37

Expert Comment

by:Joanne M. Orzech
ID: 23849162
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
 

Author Comment

by:noclew
ID: 23849408
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
 
LVL 37

Expert Comment

by:Joanne M. Orzech
ID: 23849959
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
 
LVL 37

Expert Comment

by:Joanne M. Orzech
ID: 23850010
Oh - I just realized that you've already asked the question... I found it.... I'll take a look :)
0

Featured Post

NFR key for Veeam Agent for Linux

Veeam is happy to provide a free NFR license for one year.  It allows for the non‑production use and valid for five workstations and two servers. Veeam Agent for Linux is a simple backup tool for your Linux installations, both on‑premises and in the public cloud.

Question has a verified solution.

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

After seeing numerous questions for Dynamic Data Validation I notice that most have used Visual Basic to solve the problem. This suggestion is purely formula based and can be used in multiple rows.
Lost Word File? Eagerly, need it back? Read ahead; this File Recovery guide is for you.
Learn how to create and modify your own paragraph styles in Microsoft Word. This can be helpful when wanting to make consistently referenced styles throughout a document or template.
Do you want to know how to make a graph with Microsoft Access? First, create a query with the data for the chart. Then make a blank form and add a chart control. This video also shows how to change what data is displayed on the graph as well as form…
Suggested Courses

831 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