Subject: Re: Imperonsate?
Date: Tue, 26 Aug 2003 07:49:55 -0400
Lines: 186
X-Priority: 3
X-MSMail-Priority: Normal
X-Newsreader: Microsoft Outlook Express 6.00.2800.1158
X-MimeOLE: Produced By Microsoft MimeOLE V6.00.2800.1165
Message-ID: <
[email protected]>
Newsgroups: microsoft.public.dotnet.languages.vb
NNTP-Posting-Host: 205.152.115.197
Path: cpmsftngxa06.phx.gbl!TK2MSFTNGP08.phx.gbl!tk2msftngp13.phx.gbl
Xref: cpmsftngxa06.phx.gbl microsoft.public.dotnet.languages.vb:130545
X-Tomcat-NG: microsoft.public.dotnet.languages.vb
The account that is being used is a domain account that is also a local
administrator of that machine. The print program that you gave would
probably work as a scheduled task. But, let me attach the code below so you
can see exactly what I'm doing.
Dim rngPrint As Excel.Range
Dim shp As Excel.Shape
Dim szAddress As String
Try
If TypeOf xlbook.ActiveSheet Is Excel.Worksheet Then
With xlbook.ActiveSheet
If Len(xlsheet.PageSetup.PrintArea) Then
szAddress = xlsheet.PageSetup.PrintArea Else szAddress =
xlsheet.UsedRange.Address
End With
rngPrint = xlsheet.Range(szAddress)
With rngPrint
.CopyPicture(Appearance:=Excel.XlPictureAppearance.xlScreen,
Format:=Excel.XlCopyPictureFormat.xlBitmap)
With .Parent
rngPrint.Worksheet.Paste(Destination:=rngPrint)
xlsheet.Application.ActivePrinter =
config.AppSettings("PrinterName") 'Adobe Distiller
xlsheet.Application.ActiveWindow.SelectedSheets.PrintOut(Copies:=1,
Collate:=True)
End With
End With
End If
Catch e2 As Exception
EventLog.WriteEntry("Invoices to PDF Application",
"There was an error printing/saving the PDF." & vbCrLf & e2.Message,
EventLogEntryType.Error, 1, 1)
bErrors = True
End Try
So, in this example, it is putting in the background image and then printing
off to a PDF. I am using Adobe Distiller 5.0 to accomplish this.
Joshua
Hi Joshua,
Could you tell me in what account did you run your program in?
Here is my code to test. It will be compiled as test.exe.
Private Sub Form_Load()
Dim ex As Excel.Application
Set ex = New Application
ex.Workbooks.Open "c:\a.xls"
ex.Workbooks(1).PrintOut
ex.Quit
Set ex = Nothing
MsgBox "a"
End Sub
I have try to schedule the test.exe at a time Daily or at system startup.
I can not reproduce the problem. When I am not login to the system, the
task will be executed.
The account I set in the task schedule run as is an account in
administrators groups.
You may have a try and let me know the result.
I would like you can post the code you test on your machine so that I can
reproduce the problem.
In addition, which account did you run your task in?
Regards,
Peter Huang
Microsoft Online Partner Support
Get Secure!
www.microsoft.com/security
This posting is provided "as is" with no warranties and confers no rights.