Hello,
I am trying to find a way to select another printer using a macro. For example, in Excel you can do that by using:
Application.ActivePrinter = "[PrinterName]"
...but of course that doesn't work in Coreldraw. I searched in the OLH to find the right code but I can't find it. Can smeone please help me out? So I first need to select another printer and then send the document to it using FilePrint. Thanks i.a. for your help.
Kind regards,
Tim.
Hi again,
I saw that I asked the same question in 2010 and someone replied:
Try this:
Sub printIt() With ActiveDocument.PrintSettings .SelectPrinter "myprinter" End WithEnd Sub
...but that doesn't work. Using that code, it generates an errormessage that "the property or method is not supported by this object" (Error 438). Hope I translated it right. Back then, in 2010 I also couldn't find a solution. Does anyone have other ideas? Thanks again,
Kind regards.
Just a guess, but the printer name is not exactly correct ?
To find out, you could temporarily make that printer the default printer and then browse the properties in the VBA debugger.
I don't have version 9 to test, but X7 help file suggests ActiveDocument.PrintSettings.Printer.Name should display it.
Or you could try this (tested in X7, so not necessarily applicable to v9) to show all the available printer names:
txt = "" For i = 1 To Printers.Count txt = txt + Printers(i).Name + vbLf Next i MsgBox (txt)
You can also find a printer number in Corel Draw and then use printer number instead printer name(tested on X5, VB 6.3)
Sub Macro1() Dim txt As String txt = "" For i = 1 To Printers.Count txt = txt + (i & ". " & Printers(i).Name) + vbLf Next i MsgBox (txt) PrintSettings.SelectPrinter Printers(1).Name MsgBox ("Printer " & Printers(1).Name & " selected")End Sub
Shows all printers and their numbers
and select Printer number 1 for printing.
Best regardsMek
Hi, Thanks for your reply!
More replies explained how to try to solve this issue the same way. But as is shown below, "Printers.Count" generates an error messsage:
The text is Dutch language but it says "Error 424 during runtime. Object required". Probably due to an old (too old...) version of CDR?
BUT PROBLEM SOLVED!!!
Here's what i did.
Coreldraw is controlled by an advanced macro in Excel. When an Excel-file is opened and needs to be printed then a CDR drawing needs to come with it. In some cases i need to send both documents to another printer. To do that automatically, the Excel macro starts CDR, opens the accompanying file, selects the right layers and sends it to a printer. Now, to choose another printer for CDR, i temporarily change the Windows default printer, and the macro restarts CDR. This is how it works for me:
'Declare Object for program
Set ps = CreateObject("CorelDraw.Application")
Set fs1 = CreateObject("CorelDraw.Automation.9")
'Initialize Object for Windows default printer
Set WshNetwork = CreateObject("WScript.Network")
WshNetwork.SetDefaultPrinter "Bullzip PDF Printer"
ps.Visible = True
fs1.FileOpen ( <The File Needed> )
...Do some stuff and select layers, set visible and set printable...
fs1.FilePrint
Then the last step is to set the Windows Default Printer back to the usual one. Of course the code above is only a tiny part of the entire macro but it is the main part to make it work for me. In a earlier reply someone was talking about temporarily chand the default printer and that was a good idea. So, everything works as it should right now.
Thanks everyone for helping me out and as i said before, problem solved.
Kind regard,