Level Extreme platform
Subscription
Corporate profile
Products & Services
Support
Legal
Français
Help automating Excel printout to PDF from within FoxPro
Message
From
01/02/2005 00:17:50
Nate Hastings
Ripon Community Printers
Ripon, Wisconsin, United States
 
 
To
All
General information
Forum:
Visual FoxPro
Category:
COM/DCOM and OLE Automation
Title:
Help automating Excel printout to PDF from within FoxPro
Environment versions
Visual FoxPro:
VFP 8
OS:
Windows 2000 SP4
Database:
Visual FoxPro
Miscellaneous
Thread ID:
00982586
Message ID:
00982586
Views:
102
I am using an OLE container control to automate an Excel spreadsheet. We create and manipulate data in Excel in our quoting process.

I am trying to pull up the finished cover letter, create a pdf file and email it back to the creator so it can be forwarded to the customer. Everything works great if the filename is allowed to be entered manually but when it is automated (either through FoxPro or as a macro from within Excel) the resulting pdf file created cannot be opened in Acrobat Reader. I get an error that reads "Adobe Reader could not open "filename.pdf" because it is either not a supported file type or because the file has been corrupted (for example, it was sent as an email attachment and wasn't correctly decoded)."

Here's the jist of the code to get the file into excel and prepare to print. I then use CutePDF as the print driver for output which is saved to the local c: drive.

loExcel = CreateObject("Excel.Application")
loExcel.DisplayAlerts = .F.
loExcel.Workbooks.Open(lcPathName2)
loExcel.Range("B1:I77").Select

WITH loExcel.ActiveSheet.PageSetup
.LeftHeader = ""
.CenterHeader = ""
.RightHeader = ""
.TopMargin = 0
.HeaderMargin = 0
.PrintArea="B1:I77"
.PrintHeadings = .F.
ENDWITH

*loExcel.Run("nateprint1") && this is what I tried to use to run the printing through a macro located in the excel file

loExcel.ActiveSheet.PrintOut(1,1,1,.F.,"CutePDF Printer",.T.,.T.,"C:\"+ALLTRIM(mquotenum)+".pdf") && this is how I would like to be able to enter the filename automatically without user intervention.

*loExcel.ActiveSheet.PrintOut(1,1,1,.F.,"CutePDF Printer",.F.,.T.) && this is the line I've used that works but requires the user to enter the file name in the dialog box that displays after printing.

I've tried different combinations to no avail. I would appreciate any guidance on this.

Thanks in advance,
Nate
Next
Reply
Map
View

Click here to load this message in the networking platform