OberonPlace.com Forums

OberonPlace.com Forums (http://forum.oberonplace.com/index.php)
-   CorelDRAW/Corel DESIGNER VBA (http://forum.oberonplace.com/forumdisplay.php?f=16)
-   -   VBA Select Printer? (http://forum.oberonplace.com/showthread.php?t=314)

Jon Lorber 12-12-2003 09:21

VBA Select Printer?
 
I read a few posts but I haven't been able to select a printer in CD11 in VB.

I tried this but get Object Required as the error:
Code:

Set ActiveDocument.PrintSettings.Printer = "MyPrinter"
I was able to however select a print style which has a printer associated with it with this code but I think this is just a way around my problem:

Code:

Application.ActiveDocument.PrintSettings.Load "C:\Documents and Settings\MySelf\Application Data\Corel\Graphics11\User Custom Data\Print Styles\MyPrintStyle.prs"

Alex 12-12-2003 09:36

Re: VBA Select Printer?
 
In CorelDRAW 11 you need to actually find a printer with the given name and then set to to the Printer property of PrintSettings.

Code:

Sub SetPrinter()
    Dim prn As Printer
    Dim n As Long
   
    Set prn = Nothing
    For n = 1 To Printers.Count
        If Printers(n).Name = "MyPrinter" Then
            Set prn = Printers(n)
            Exit For
        End If
    Next n
   
    If prn Is Nothing Then
        MsgBox "Printer not found", vbCritical
    Else
        Set ActiveDocument.PrintSettings.Printer = prn
        ' Do the printing here
    End If
End Sub

In CorelDRAW 12, however, there will be a method PrintSettings.SelectPrinter which will allow to do all the above in one shot:

Code:

ActiveDocument.PrintSettings.SelectPrinter "MyPrinter"


All times are GMT -5. The time now is 09:00.

Powered by vBulletin® Version 3.8.1
Copyright ©2000 - 2021, Jelsoft Enterprises Ltd.
Copyright © 2011, Oberonplace.com