IAC - How to convert Excel Chart to PDF using PDFWriter
May 22, 2000
A VB program that automatically converts Excel Charts to PDF
Format. A file list of Excel Charts, and a file list of the pdf names is
This code sample is posted here for the general benefit of the PDF development community. Attribution and usage guidelines are as noted in the code source; please respect the wishes of the author when using this code.
' This program converts EXCEL format charts to PDF
' format (WIN-NT). It reads in a list of file names from a file
' and then converts those files to PDF format. It also
' edits the _pdf.ini file to allow this task to take place
' This program reads in a list of EXCEL file names from a file
' into an array. It also reads the corresponding list of pdf files
' into another array. The file order and names are the same, except for the
' file extenstion.
' It removes any files with a ".old" extension. It then renames
' the original PDF files with the extension ".old", and creates the
' new odf files.
'On Error Resume Next ' Just ignore any files that are not found
Application ' EXCEL Application
Workbook ' EXCEL Workbook
' Hold the .xls file name
' Hold the .pdf file name
' Counter for array
NewName ' Change names of converted files.
XA = Excel.
Application 'Set up Excel Application in VB
'To hold the pdf generated file name
'used when opening _pdf.ini
PDFFilename = "c:\xlsfiles\file.pdf" 'file & path name for the pdf
'Kill "c:\xlsfiles\testing\*.old" 'Delete all the old pdf files
i = 1 ' size of array for the pdf files
pdfarraysize = FileLen(
'declare array for reading in PDF files
'delclare array for renaming pdf files
#2 'open file for input
Cntr = 0Do
' Check for end of file, this file is the same as #2
only extensions are different. Line
= pdfformat 'read file names into array pdfArrayold(
= pdfformat & ".old" ' read file names
in, adding .old extension OldName = pdfArray(
: NewName = pdfArrayold(
Cntr) 'Name OldName As NewName ' Move and rename file. 'renaming original
pdf file with .old Cntr = Cntr + 1Loop
' Update the __pdf.ini file
' The variables can be set to anything you want. These are just the
values' I had in the original .ini file
"ErrFlag = 0"Print
"szTitle = file.PDF"Print
"szAuthor = adaly01"Print
"szProducer=Acrobat PDFWriter 3.03 for Windows NT"Print
"szCreator = Project1 - Microsoft; Visual; Basic; [run] -
"startDocTitle = file.xls"Print
"FileNameSet = 0"Print
"orient = 2"Print
PDFView = True
"bExecViewer = 1"
InstallarraySize = FileLen(
'get size of EXCEL
#1 'open file for input
' Check for end of file
CurrentLine ' Read line of data.
XC = XA.
) ' Print each worksheet to the PDF
Worksheets ' The file created is "c:\xlsfiles\file.pdf
OldName = PDFFilename: NewName = pdfArray(
Count) 'Name OldName As NewName ' Move and rename file.
Count = Count + 1Loop
' Close any workbooks
#1 ' Close "c:\xlsfiles\list.txt"
#2 ' Close "c:\xlsfiles\pdflist.txt"
' Closes the form
OK, so you want to stamp your document. Maybe you need to give reviewers some advice about the document's status or sensitivity. This tip from author Ted Padova demonstrates how to add stamps with the Stamp Tool along with related comments.