Still celebrating National IT Professionals Day with 3 months of free Premium Membership. Use Code ITDAY17

x
?
Solved

Need a way to create PDF files using VBA code

Posted on 2013-05-17
5
Medium Priority
?
1,787 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
[X]
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
  • 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

New benefit for Premium Members - Upgrade now!

Ready to get started with anonymous questions today? It's easy! Learn more.

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.
Access developers frequently have requirements to interact with Excel (import from or output to) in their applications.  You might be able to accomplish this with the TransferSpreadsheet and OutputTo methods, but in this series of articles I will di…
This Micro Tutorial will demonstrate how to use a scrolling table in Microsoft Excel using the INDEX function.
Many functions in Excel can make decisions. The most simple of these is the IF function: it returns a value depending on whether a condition you describe is true or false. Once you get the hang of using the IF function, you will find it easier to us…

670 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