ActivePrinter in Excel changes!

G

Guest

During a long running excel macro that also sets page margins and headers, I
set the activeprinter at the start of the macro but it changes dynamically if
the system default printer changes during the macro's execution. This causes
the macro to fail. Is there some property that can be set to not allow the
activeprinter to be changed? The biggest problem occurs on terminal services
when a user logs off and are left without any default printer assignment
which causes excel to prompt for one. My macro runs unattended so it just
hangs waiting for user input.

Please help!
 
G

Guest

Why not set the active printer in the Before_Print event in ThisWorkbook
instead of a t the beginning of execution?
 
G

Guest

The macro doesn't print - it just prepares it for printing so users can print
on their printer. The question are: why does the activeprinter change? And
How can I prevent it from changing?

Thanks,
Gary..
 
G

Guest

I assume you are using

Application.Activeprinter = "??"

This does not change anything in the actual workbook itself. It only changes
the instance of Excel (application) that you are currently working in... I am
not sure exactly what you are doing with this book... Do you run it and then
save it and distribute it to end users. If so then the active printer
associated with their application will be the one that is used...
 
G

Guest

Yes I set it that way. My VB application runs in batch overnight to prepare
reports for end users. In order for my excel macro to format the xls file for
end user printing (setting margins, headers and landscape) it needs to have
an active printer set. Not an actual printer, it just needs a print driver
installed which the system has setup. This all works fine except that excel
will change the active printer to a terminal server user's printer. When this
user then logs off, the system is left without a default printer and excel
now has an invalid ActivePrinter, not the one I set.

This application is on Windows Server 2003 and Office 2003.

Thanks again,
Gary Smith
 
G

Guest

There is not much I can help you here. I don't think Excel really is the
problem here. It sounds more like an issue with the application being server
based and how the printers are being handled by the server. Or possibly it
has to do with restrictions placed on the application to allow/disallow users
from modifying (persistently) setting such as printers.
 

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