Solved

Need a way to create PDF files using VBA code

Posted on 2013-05-17
5
1,554 Views
Last Modified: 2013-05-30
Hey Experts,

I have an Excel spreadsheet that currently uses VBA code to create a PDF report from an Excel sheet using the Adobe Distiller (version 5.0, I believe) on a very old computer. I have heard that the Distiller has been discontinued.

Although I could switch to creating the PDF manually, if necessary, I was wondering if somebody had some VBA code to create a PDF file using Adobe or preferably one of the less expensive PDF tools like CutePDF Writer or Nitro, etc.

Please let me know any suggestions you might have.

Thanks,

TaDuh
0
Comment
Question by:taduh
  • 3
5 Comments
 
LVL 2

Expert Comment

by:mensmaximus
ID: 39174723
Some time ago I had to create PDFs from Excel with pdf24. I just installed the PDF printer and put the printer name into my printout routine.

ActiveSheet.PrintOut ActivePrinter:="PDF24"

Open in new window

0
 
LVL 7

Accepted Solution

by:
BT15 earned 500 total points
ID: 39174891
which version of Excel?

if you have excel 2010 (or 2007 with the "Save as XPS/PDF" add-in, you can do PDFs directly like so (sampled from http://www.mrexcel.com/forum/excel-questions/405000-2007-excel-saveas-pdf-visual-basic-applications.html)

Sub Macro1()
Dim wsh As Worksheet, vWshs, vWshName

vWshs = Array("Sheet1", "Sheet3", "Sheet4")
With ActiveWorkbook
    For Each vWshName In vWshs
        .Worksheets(vWshName).ExportAsFixedFormat Type:=xlTypePDF, Filename:= _
            "C:\Tmp\" & vWshName, Quality:=xlQualityStandard, _
            IncludeDocProperties:=True, IgnorePrintAreas:=False, OpenAfterPublish:=False
    Next vWshName
End With
End Sub
0
 

Author Comment

by:taduh
ID: 39175333
mensmaximus,

I am checking with my IT department about the possibility of uinstalling PDF24 so I can test your solution.

taduh
0
 

Author Comment

by:taduh
ID: 39175351
BT15,

I am currently on Excel 3.0 because we use a dinosaur application with an Excel add-in that my IT guys thought required that version. They have since found out that it will work with Excel 7.0, so I could upgrade and test your solution. I will contact my IT department about doing so.

taduh
0
 

Author Closing Comment

by:taduh
ID: 39208227
I've not gotten to test the code yet - that's why I graded as a B rather than an A, but I'm scheduled to get upgraded to Excel 7.0 soon and my tech support guy is familiar with the Save as XPS/PDF add-in, so I think I'm good to go.

Thanks BT15!

taduh
0

Featured Post

Is Your Active Directory as Secure as You Think?

More than 75% of all records are compromised because of the loss or theft of a privileged credential. Experts have been exploring Active Directory infrastructure to identify key threats and establish best practices for keeping data safe. Attend this month’s webinar to learn more.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Suggested Solutions

A little background as to how I came to I design this code: Around 5 years ago I designed an add-in that formatted Excel files to a corporate standard, applying different cell colours and font type depending on whether the cells contained inputs,…
Some code to ensure data integrity when using macros within Excel. Also included code that helps secure your data within an Excel workbook.
This Micro Tutorial will demonstrate on a Mac how to change the sort order for chart legend values and decrpyt the intimidating chart menu.
In this fifth video of the Xpdf series, we discuss and demonstrate the PDFdetach utility, which is able to list and, more importantly, extract attachments that are embedded in PDF files. It does this via a command line interface, making it suitable …

910 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question

Need Help in Real-Time?

Connect with top rated Experts

16 Experts available now in Live!

Get 1:1 Help Now