Solved

Need a way to create PDF files using VBA code

Posted on 2013-05-17
5
1,525 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

Top 6 Sources for Identifying Threat Actor TTPs

Understanding your enemy is essential. These six sources will help you identify the most popular threat actor tactics, techniques, and procedures (TTPs).

Join & Write a Comment

This article describes some techniques which will make your VBA or Visual Basic Classic code easier to understand and maintain, whether by you, your replacement, or another Experts-Exchange expert.
If you need to start windows update installation remotely or as a scheduled task you will find this very helpful.
This Micro Tutorial demonstrates how to create Excel charts: column, area, line, bar, and scatter charts. Formatting tips are provided as well.
This Micro Tutorial will demonstrate how to use a scrolling table in Microsoft Excel using the INDEX function.

757 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

17 Experts available now in Live!

Get 1:1 Help Now