Consultor Eletrônico



Kbase P134758: Cannot insert PDF file into an Excel sheet using the ADD method
Autor   Progress Software Corporation - Progress
Acesso   Público
Publicação   22/09/2008
Status: Unverified

SYMPTOM(s):

Cannot insert PDF file into an Excel sheet using the ADD method

Using the method chWorkpicture = chWorkSheet:OLEObjects:ADD("AcroExch.Document.7",,,,"filename.pdf",,,,,,) , a dialog box systematically opens up for the user to select a file to insert

FACT(s) (Environment):

OpenEdge 10.1B
Windows

CAUSE:

The phrase phrase chWorkSheet:OLEObjects:ADD("AcroExch.Document.7",,,,"filename.pdf",,,,,,) contains 2 errors: You must specify either a ClassType, or a FileName. Both are mutually exclusive and will return errors if both are specified FileName must be entered in second position

FIX:

The ADD method contains 7 arguments, and must all be specified in the right order, even for nul arguments. Please find below a peice of source code that will allow you to insert any type of file into an Excel sheet: DEF VAR chExcel AS COM-HANDLE NO-UNDO.
DEF VAR chBook AS COM-HANDLE NO-UNDO.
DEF VAR chSheet AS COM-HANDLE NO-UNDO.
DEF VAR fileNa AS CHAR.
DEF VAR chInsertPDF AS CHAR.
fileNa = "filePath\fileName.pdf". CREATE "Excel.Application" chExcel NO-ERROR.
ASSIGN chExcel:VISIBLE = TRUE. chBook = chExcel:Workbooks:Add().
chSheet = chExcel:Sheets:Item(1).
chInsertPDF = chSheet:OLEObjects:ADD(,fileNa,,,,,):SELECT.