Go Premium for a chance to win a PS4. Enter to Win

x
?
Solved

Need a way to create PDF files using VBA code

Posted on 2013-05-17
5
Medium Priority
?
1,810 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 1500 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

Independent Software Vendors: We Want Your Opinion

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

Question has a verified solution.

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

When you see single cell contains number and text, and you have to get any date out of it seems like cracking our heads.
This article describes how to use a set of graphical playing cards to create a Draw Poker game in Excel or VB6.
This video Micro Tutorial shows how to password-protect PDF files with free software. Many software products can do this, such as Adobe Acrobat (but not Adobe Reader), Nuance PaperPort, and Nuance Power PDF, but they are not free products. This vide…
In a question here at Experts Exchange (https://www.experts-exchange.com/questions/29062564/Adobe-acrobat-reader-DC.html), a member asked how to create a signature in Adobe Acrobat Reader DC (the free Reader product, not the paid, full Acrobat produ…

972 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