Preset output filename & Bypass 'Save As' dialogue after sending document to pdf printer VB6

897 Views Asked by At

Working on a legacy application. im looking for a way to preset the output filename & Bypass 'Save As' dialogue after sending document to pdf printer VB6. Im printing a report but i want to programmatically set the filename and avoid seeing the 'save as' common dialog. Pls help

'Determine Default Printer
    
Dim PrintData As Printer
Dim defprinterpos%
Lstprinter.Clear
For Each PrintData In Printers
    ' Add printer name and port to list
    Lstprinter.AddItem PrintData.DeviceName '& " at: " & PrintData.Port
    ' Check for default printer
    If PrintData.DeviceName = Printer.DeviceName Then defprinterpos = Lstprinter.NewIndex
Next
Lstprinter.ListIndex = defprinterpos%
    frmmain.lblPrinter.Caption = Lstprinter.List(Lstprinter.ListIndex)
    
   ' SetPrinter ("Microsoft Print to PDF")
   If Check4.Value = 1 Then
                Dim PrinterName As String
                PrinterName = "Microsoft Print to PDF" '"CutePDF Writer"
                Dim w As New WshNetwork
                w.SetDefaultPrinter (PrinterName)
                Set w = Nothing
  End If
    
    ' print the Sales Invoice
   rptsales.printreport
    
0

There are 0 best solutions below