Is there a vba method I can use to populate a popup dropdown menu with array items? I want to allow the user to select a printer from a list generated by the following code:
Is that possible?
Also, I know I can then set a new default printer with objPrinter.SetDefaultPrinter.. but is there a way I can return only the default printer in the same format, so that I can store it while the macro runs, then restore it when it completes?
Code:
Dim objPrinter As Object
Dim arrPrinters() As Variant
Dim prCount As Integer
Set objPrinter = CreateObject("wscript.network")
For Each printer In objPrinter.enumprinterconnections
If (IsNumeric(InStr(printer, "\\")) And InStr(printer, "\\") <> 0) Or ((IsNumeric(InStr(LCase(printer), "pdf"))) And InStr(LCase(printer), "pdf")) Then
ReDim Preserve arrPrinters(0 To prCount)
arrPrinters(prCount) = printer
Debug.Print printer
prCount = prCount + 1
End If
Next printer
Set objPrinter = Nothing
Is that possible?
Also, I know I can then set a new default printer with objPrinter.SetDefaultPrinter.. but is there a way I can return only the default printer in the same format, so that I can store it while the macro runs, then restore it when it completes?