OK, I've added this to the window that the report prints from, I see this in name printers have this assigned to a printer. But when I print the report it uses my default printer .... not the named printer. Hopefully you can point me in the right direction. I'm not trained in VBA but am familiar with SQL and Progress languages.
Thanks
Dedra
Option Explicit
Private Sub Window_AfterOpen()
'Dim CompilerApp As New Dynamics.Application
Dim CompilerApp As Object
Dim CompilerMessage As String
Dim CompilerError As Integer
Dim Commands As String
' Create link without having reference marked
Set CompilerApp = CreateObject("Dynamics.Application")
' Commands to Add a Printer Task into the Named Printer Assign window
' Parameters are Series, Task ID (up to 15 chars) and Description (up to 50 chars)
Commands = ""
Commands = Commands & "ST_Set_Printer_Task(10, ""CINCH_PUR"", ""Purchase Contract Cash - Contract Printer""); " & vbCrLf
'MsgBox Commands
' Execute SanScript
CompilerError = CompilerApp.ExecuteSanscript(Commands, CompilerMessage)
If CompilerError <> 0 Then
MsgBox CompilerMessage
End If
End Sub
Private Sub WindowPrint_BeforeUserChanged(KeepFocus As Boolean, CancelLogic As Boolean)
'Dim CompilerApp As New Dynamics.Application
Dim CompilerApp As Object
Dim CompilerMessage As String
Dim CompilerError As Integer
Dim Commands As String
' Create link without having reference marked
Set CompilerApp = CreateObject("Dynamics.Application")
' Commands to Change the Default Application Printer based on settings in Named Printers
' Parameters are Series and Task ID (up to 15 chars)
Commands = ""
Commands = Commands & "local 'Printer Settings' NamedPrinter; " & vbCrLf
Commands = Commands & "NamedPrinter = ST_Set_To_Default_Printer(10, ""CINCH_PUR""); " & vbCrLf
Commands = Commands & "if not empty(NamedPrinter) then"
Commands = Commands & " Printer_SetDestination(NamedPrinter);"
Commands = Commands & "end if;"
'MsgBox Commands
' Execute SanScript
CompilerError = CompilerApp.ExecuteSanscript(Commands, CompilerMessage)
If CompilerError <> 0 Then
MsgBox CompilerMessage
End If
End Sub
Private Sub WindowPrint_AfterUserChanged()
'Dim CompilerApp As New Dynamics.Application
Dim CompilerApp As Object
Dim CompilerMessage As String
Dim CompilerError As Integer
Dim Commands As String
' Create link without having reference marked
Set CompilerApp = CreateObject("Dynamics.Application")
' Commands to restore the Default Application Printer based on settings in Named Printers
' This will restore to the System Default Printer first and then to the Company Default Printer
Commands = ""
Commands = Commands & "local 'Printer Settings' NamedPrinter; " & vbCrLf
Commands = Commands & "NamedPrinter = ST_Set_To_Default_Printer(7,ST_DEFAULT); " & vbCrLf
Commands = Commands & "if not empty(NamedPrinter) then"
Commands = Commands & " Printer_SetDestination(NamedPrinter);"
Commands = Commands & "end if;"
Commands = Commands & "NamedPrinter = ST_Set_To_Default_Printer(8,ST_DEFAULT); " & vbCrLf
Commands = Commands & "if not empty(NamedPrinter) then"
Commands = Commands & " Printer_SetDestination(NamedPrinter);"
Commands = Commands & "end if;"
'MsgBox Commands
' Execute SanScript
CompilerError = CompilerApp.ExecuteSanscript(Commands, CompilerMessage)
If CompilerError <> 0 Then
MsgBox CompilerMessage
End If
End Sub