09-02-2016 2:22 AM
Experts,
Yesterday I tried to save a file.xlsx as file.pdf by ole coding and failed,
then i did the same thing on file.docx and succeeded.
So i 'm confused now and hope to make it clear whether it's possible to save a EXCEL as PDF by ole coding....
Below is my test coding of saving file.docx.
Any help will be appreciated *_*.
CREATE OBJECT lv_wordapp 'word.application'.
SET PROPERTY OF lv_wordapp 'Visible' = 0.
CALL METHOD OF lv_wordapp 'Documents' = lv_worddoc.
CALL METHOD OF lv_worddoc 'Open'
EXPORTING
#1 = 'C:\Users\Administrator\Desktop\test.docx'.
CALL METHOD OF lv_wordapp 'ActiveDocument' = lv_wordadoc.
CALL METHOD OF lv_wordadoc 'Content' = lv_wordcont.
CALL METHOD OF lv_wordadoc 'SaveAs'
EXPORTING
#1 = 'C:\Users\Administrator\Desktop\test.pdf'
#2 = 17. "save as a PDF file
CALL METHOD OF lv_wordapp 'Quit'.
FREE OBJECT lv_wordapp .
Best Regards
Panda
09-02-2016 9:55 PM
Hi Panda,
I took your code and test creating from XLSX to PDF extension and works fine! Check code.
DATA: lv_wordapp TYPE ole2_object,
lv_worddoc TYPE ole2_object,
lv_wordadoc TYPE ole2_object,
lv_wordcont TYPE c LENGTH 8.
CREATE OBJECT lv_wordapp 'word.application'.
SET PROPERTY OF lv_wordapp 'Visible' = 0.
CALL METHOD OF lv_wordapp 'Documents' = lv_worddoc.
CALL METHOD OF lv_worddoc 'Open'
EXPORTING
#1 = 'E:\Test\documento.xlsx'.
CALL METHOD OF lv_wordapp 'ActiveDocument' = lv_wordadoc.
CALL METHOD OF lv_wordadoc 'Content' = lv_wordcont.
CALL METHOD OF lv_wordadoc 'SaveAs'
EXPORTING
#1 = 'E:\Test\documento.pdf'
#2 = 17. "save as a PDF file
CALL METHOD OF lv_wordapp 'Quit'.
FREE OBJECT lv_wordapp .
Regards,
09-02-2016 9:55 PM
Hi Panda,
I took your code and test creating from XLSX to PDF extension and works fine! Check code.
DATA: lv_wordapp TYPE ole2_object,
lv_worddoc TYPE ole2_object,
lv_wordadoc TYPE ole2_object,
lv_wordcont TYPE c LENGTH 8.
CREATE OBJECT lv_wordapp 'word.application'.
SET PROPERTY OF lv_wordapp 'Visible' = 0.
CALL METHOD OF lv_wordapp 'Documents' = lv_worddoc.
CALL METHOD OF lv_worddoc 'Open'
EXPORTING
#1 = 'E:\Test\documento.xlsx'.
CALL METHOD OF lv_wordapp 'ActiveDocument' = lv_wordadoc.
CALL METHOD OF lv_wordadoc 'Content' = lv_wordcont.
CALL METHOD OF lv_wordadoc 'SaveAs'
EXPORTING
#1 = 'E:\Test\documento.pdf'
#2 = 17. "save as a PDF file
CALL METHOD OF lv_wordapp 'Quit'.
FREE OBJECT lv_wordapp .
Regards,
09-03-2016 9:28 AM
I think the OP question was to convert the Excel file into a PDF via the excel.application, but it's fun if it works using Word 😛
09-18-2016 2:29 AM
Hi David,
The case with 'Word.application' is ok.
I just want to do the same thing with 'Excel.application'.
However, the PDF file which is generated from EXCEL is not available to open.
This is my question and i hope somebody could give me a successful example.