Advertisement

12.11.2007 at 04:10AM PST, ID: 23015218
[x]
Attachment Details

Saving Excel as PDF from VBA

Asked by edjones1 in Access Coding/Macros, VB Controls, VB Script

Tags: vba, pdf, access, excel

Hi

I am developing an Access 2007 application which needs to manipulate an Excel 2007 document.  The VBA needs to save an existing Excel doc as a PDF using the Office 2007 Save as PDF add-in which is installed.

So far I have the following code

Dim xlWorkBook As workBook
                Dim PDFxlWorkBook As workBook
   
                Set xlWorkBook = Workbooks.Open("J:\Test.xls")

                xlWorkBook.Application.DisplayAlerts = False
                xlWorkBook.SaveAs "J:\test.txt"
                xlWorkBook.SaveAs "J:\test.csv"

This all works very well and produces the expected results.  However when I add the line

                xlWorkBook.SaveAs "J:\test.pdf"

The file is generated but obviously it is not a PDF doc just a file with a .pdf extension name thus rendering it unreadable as a PDF.

I have found the following command which will apparently save the Excel doc as a PDF but I cannot get it to work

xlWorkbook.ExportAsFixedFormat(xlTypePDF,"J:\Test.pdf",xlQualityMinimum)

Any help would be appreciated
Start Free Trial
[+][-]12.11.2007 at 04:17AM PST, ID: 20448726

View this solution now by starting your 7-day free trial. Setting up your free trial is quick, easy, and secure. We will return you to this solution, unlocked, when you're done.

 

About this solution

Zones: Access Coding/Macros, VB Controls, VB Script
Tags: vba, pdf, access, excel
Sign Up Now!
Solution Provided By: sognoct
Participating Experts: 2
Solution Grade: B
 
 
[+][-]12.11.2007 at 07:23AM PST, ID: 20449868

Assisted solutions are selected by the member who asked the question as a comment that contributed to their question's solution.

Start your 7-day free trial to view this Assisted Solution or ask the Experts your question.

 
[+][-]12.12.2007 at 03:48AM PST, ID: 20456416

Often, when Experts are collaborating with members who have asked questions, they will request additional information about the problem. Askers respond with an author comment like this one.

Start your 7-day free trial to view this Author Comment or ask the Experts your question.

 
 
Loading Advertisement...
20080716-EE-VQP-32 / EE_QW_2_20070628