[VBA-CE U14] Get active Windows Printer name

Hi,

I am trying to get some information about the active printer.  This routine give me the Print Driver Name, the paper name, and the orientation.  What I am really missing is the Windows Printer Name.

How do I get the Windows Printer Name?  (IE. I can get a result of "Printer.pltcfg", but I also need to get the "HPOfficeJetPro" name from the active Windows printer.)

Sub ActivePrinterSettings()
    Dim Result As String
    CadInputQueue.SendCommand "DIALOG PLOT "
    Result = GetCExpressionValue("plotUI.uiPrinterName")
    Result = Result & vbNewLine & GetCExpressionValue("plotUI.uiPaperName")
    Result = Result & vbNewLine & IIf(GetCExpressionValue("plotUI.uiOrientation") = 0, "Portrait", "Landscape")
    Result = Result & vbNewLine & GetCExpressionValue("plotUI.uiFormSizeX") & ", " & GetCExpressionValue("plotUI.uiFormSizeY")
    MsgBox Result
End Sub

--Thanks,
--Robert Arnold

Parents
  • Hi,

    Per , There is another CExpression: "plotUI.uiSysPrinterName" which returns the name of the selected printer. E.g. if  the expression "plotUI.uiPrinterName" returns "Windows printer", the expression "plotUI.uiSysPrinterName" returns the exact name of the selected Windows printer name.

    That means that my expanded test looks like:

    Sub ActivePrinterSettings()
        Dim Result As String
        CadInputQueue.SendCommand "DIALOG PLOT "
        Result = GetCExpressionValue("plotUI.uiPrinterName")
        Result = Result & vbNewLine & GetCExpressionValue("plotUI.uiSysPrinterName")
        Result = Result & vbNewLine & GetCExpressionValue("plotUI.uiPaperName")
        Result = Result & vbNewLine & IIf(GetCExpressionValue("plotUI.uiOrientation") = 0, "Portrait", "Landscape")
        Result = Result & vbNewLine & GetCExpressionValue("plotUI.uiFormSizeX") & ", " & GetCExpressionValue("plotUI.uiFormSizeY")
        MsgBox Result
    End Sub

    Thanks again for all the suggestions.

    --Thanks,
    --Robert

    Answer Verified By: RobertArnold 

Reply
  • Hi,

    Per , There is another CExpression: "plotUI.uiSysPrinterName" which returns the name of the selected printer. E.g. if  the expression "plotUI.uiPrinterName" returns "Windows printer", the expression "plotUI.uiSysPrinterName" returns the exact name of the selected Windows printer name.

    That means that my expanded test looks like:

    Sub ActivePrinterSettings()
        Dim Result As String
        CadInputQueue.SendCommand "DIALOG PLOT "
        Result = GetCExpressionValue("plotUI.uiPrinterName")
        Result = Result & vbNewLine & GetCExpressionValue("plotUI.uiSysPrinterName")
        Result = Result & vbNewLine & GetCExpressionValue("plotUI.uiPaperName")
        Result = Result & vbNewLine & IIf(GetCExpressionValue("plotUI.uiOrientation") = 0, "Portrait", "Landscape")
        Result = Result & vbNewLine & GetCExpressionValue("plotUI.uiFormSizeX") & ", " & GetCExpressionValue("plotUI.uiFormSizeY")
        MsgBox Result
    End Sub

    Thanks again for all the suggestions.

    --Thanks,
    --Robert

    Answer Verified By: RobertArnold 

Children
No Data