Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people, just like you, are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
Solved

Need a way to create PDF files using VBA code

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

Free Tool: SSL Checker

Scans your site and returns information about your SSL implementation and certificate. Helpful for debugging and validating your SSL configuration.

One of a set of tools we are providing to everyone as a way of saying thank you for being a part of the community.

Question has a verified solution.

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

*Adobe Acrobat 9 was used for this article.  Particular steps may vary depending on software versions. Adobe Acrobat has many, many variables that my be utilized to customize your forms for clarity and ease of use. The Form Editing Tool will be y…
Do you use a spreadsheet like Microsoft's Excel?  Have you ever wanted to link out to a non excel file on your computer or network drive?  This is the way I found to do it!
Although Jacob Bernoulli (1654-1705) has been credited as the creator of "Binomial Distribution Table", Gottfried Leibniz (1646-1716) did his dissertation on the subject in 1666; Leibniz you may recall is the co-inventor of "Calculus" and beat Isaac…
Finds all prime numbers in a range requested and places them in a public primes() array. I've demostrated a template size of 30 (2 * 3 * 5) but larger templates can be built such 210  (2 * 3 * 5 * 7) or 2310  (2 * 3 * 5 * 7 * 11). The larger templa…

839 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