|
Home > Archive > MS SQL Server DTS > July 2005 > Net Work Print Question
You are viewing an archived Text-only version of the thread.
To view this thread in it's original format and/or if you want to reply to
this thread please [click here]
| Author |
Net Work Print Question
|
|
| Leslie 2005-07-25, 8:29 pm |
| I am trying to print a document to a specific network printer in DTS using an
ActiveX VB script. I found the code below in another group, however, I'm
getting a compile error when I try executing it, and I'm unsure why.
(Expected End of Statement on Line 14)
JoeO:"You use printer collection to select your desired printer as long
as that printer is in the user's system printer collection.
Dim X As Printer
For Each X In Printers
If X.DeviceName = "MyTargetPrinter" Then
' Set printer as system default.
Set Printer = X
' Stop looking for a printer.
Exit For
End If
Next
'Then print to X " -- End JoeO extract
This is the full code:
Function Main()
Main = DTSTaskExecResult_Su
ccess
' DECLARATIONS:
Dim XLPrinter as Printer
Dim XLApp
Dim XLWkb
Dim XLWkSht
'SET VARIABLES:
Set XLApp = CreateObject("Excel.Application")
XLWkb = " C:\SQLData\MSSQL\JOB
S\reports\SoftSeatPl
anningReportBAK.xls"
XLWkSht = "Shock Blocker Monthly Report"
xlapp.visible = true
'PROCESS (PRINT) WORKSHEET:
For Each XLPrinter In Printers
If XLPrinter.DeviceName = "AcctPrinter" Then
' Set printer as system default.
Set Printer = "AcctPrinter"
' Stop looking for a printer.
Exit For
End If
Next
xlapp.workbooks.open XLWkb
xlapp.activeworkbook.worksheets(XLWkSht).printout
'CLOSE AND EXIT:
xlapp.ActiveWorkbook.Saved = True
xlapp.ActiveWorkbook.Close
xlapp.quit
End Function
Thanks!
Leslie
| |
| Leo Matter 2005-07-26, 3:24 am |
| isn't it that
' DECLARATIONS:
Dim XLPrinter as Printer
you should comment out the as printer
"Leslie" <Leslie@discussions.microsoft.com> wrote in message
news:32EDB38E-3CB7-43DF-8E19- D04B46B756D2@microso
ft.com...
>I am trying to print a document to a specific network printer in DTS using
>an
> ActiveX VB script. I found the code below in another group, however, I'm
> getting a compile error when I try executing it, and I'm unsure why.
> (Expected End of Statement on Line 14)
>
> JoeO:"You use printer collection to select your desired printer as long
> as that printer is in the user's system printer collection.
>
> Dim X As Printer
> For Each X In Printers
> If X.DeviceName = "MyTargetPrinter" Then
> ' Set printer as system default.
> Set Printer = X
> ' Stop looking for a printer.
> Exit For
> End If
> Next
>
> 'Then print to X " -- End JoeO extract
>
> This is the full code:
>
> Function Main()
> Main = DTSTaskExecResult_Su
ccess
>
> ' DECLARATIONS:
> Dim XLPrinter as Printer
> Dim XLApp
> Dim XLWkb
> Dim XLWkSht
>
> 'SET VARIABLES:
> Set XLApp = CreateObject("Excel.Application")
> XLWkb = " C:\SQLData\MSSQL\JOB
S\reports\SoftSeatPl
anningReportBAK.xls"
> XLWkSht = "Shock Blocker Monthly Report"
> xlapp.visible = true
>
> 'PROCESS (PRINT) WORKSHEET:
> For Each XLPrinter In Printers
> If XLPrinter.DeviceName = "AcctPrinter" Then
> ' Set printer as system default.
> Set Printer = "AcctPrinter"
> ' Stop looking for a printer.
> Exit For
> End If
> Next
> xlapp.workbooks.open XLWkb
> xlapp.activeworkbook.worksheets(XLWkSht).printout
>
> 'CLOSE AND EXIT:
> xlapp.ActiveWorkbook.Saved = True
> xlapp.ActiveWorkbook.Close
> xlapp.quit
>
> End Function
>
> Thanks!
> Leslie
| |
| Leslie 2005-07-26, 11:24 am |
| Leo,
You are correct that it is the "as printer" which is having the problem. I
was counting the active lines in the code for line number, not including
comment lines. I re-ran the code in Access' VB Debugger and it was
definitely the Dim statement having the problem. I will try removing the "as
printer" and see if I can get a clean compile.
Cheers,
Leslie
"Leo Matter" wrote:
> isn't it that
> ' DECLARATIONS:
> Dim XLPrinter as Printer
>
> you should comment out the as printer
>
> "Leslie" <Leslie@discussions.microsoft.com> wrote in message
> news:32EDB38E-3CB7-43DF-8E19- D04B46B756D2@microso
ft.com...
>
>
>
|
|
|
|
|