Problems with printer switching
Hello, I've got the following problem.
I need to use two printers for different purposes. At first I used Set Application.Printer = Application.Printers(printername) to choose a printer and switch between a certain printer and the default printer. Everything worked fine but the problem was that this code could only be used with access 2002/3/xp and not with 2000. So I used the function
Public Sub SetDefaultPrinter(s As String)
'imposta la stampante passata come argomento a predefinita
On Error GoTo Esci
Dim WshNetwork As Object
If IsNull(s) Or s = "" Then Exit Sub
Set WshNetwork = CreateObject("WScript.Network")
WshNetwork.SetDefaultPrinter (s)
Set WshNetwork = Nothing
DoEvents
Esci:
End Sub
and it appears that this code works with access2000 but not access 2002. If I write
SetDefaultPrinter pdfPrinter
....
SetDefaultPrinter defaultPrinter
the second function call is executed but has no effect on the printers. I found out that the function works just the first time I run the routine.
I mean, if the printer is pdfPrinter, for example, and I delete the line SetDefaultPrinter pdfPrinter, there's no way to choose defaultPrinter. If I shut down access and then reload it, the call SetDefaultPrinter defaultPrinter works. (and vice versa)
I don't know how to solve the problem, it happens just with access2002 as far as I know.
Thanks
|