Conversion to PDF

  • Thread starter Thread starter FuzzyLogic
  • Start date Start date
It is possible, but you will need to have a copy of Adobe Acrobat to do
this. Adobe will put in a pdf maker into the list of printers, so that
when you want a pdf file you select this from the printer selection, it
will then output a file instead of actually printing it.

Hope this helps.

Mike
 
I believe you will have to have a full version of Acrobat to convert an
Excel file that has more than one worksheet to a PDF.
 
Sorry, I have not mentioned the details about my R&D in this context.

I have done this thing but it work fine interactively.
But I have to do this in VB Batch Process.
So, the same thing does not seem possible programmatically because my
objective is not to change the default printer on the user.

But I wanted to do the job in the following way:

Select the PDF Writer as printer on runtime
and then execute Print Command from Excel's Instance (Object). But it
did not works properly and often shows the printers dialog
of that computer to select the printer.


.......
 
Hi

Search for Pdf995 with google. When you don't mind about a couple of
advertising banners in program's desktop header, then it's free.
 
http://www.planetpdf.com/


Jim Rech on writing a PDF

http://www.deja.com/getdoc.xp?AN=652844427&fmt=text

From: "Jim Rech" <[email protected]>
Subject: Re: Disable keyboard for SendKeys
Date: 31 Jul 2000 00:00:00 GMT
Message-ID: <#wktr0w#$GA.196@cppssbbsa04>
References: <O6ZU5Mw#[email protected]>
<uhXnsew#[email protected]>
<uy03Xtw#[email protected]>
X-Priority: 3
X-MimeOLE: Produced By Microsoft MimeOLE V5.50.4133.2400
X-MSMail-Priority: Normal
Newsgroups: microsoft.public.excel.programming

What follows is a note I wrote some time ago on batch printing to a PDF
"printer". It's a lot better than sendkeys.

-------
The PDF driver looks for entries in an INI file and uses them for file names
automatically. If it doesn't find these entries then it prompts the user
for a file name. So your process would have to make these entries before
printing each workbook to the PDF "printer".

BTW, the INI file it looks for is "PDFWritr.ini" in the Windows\System
directory. So...

To write entries to INI files using the Windows API you need to have this
declarations at the top of your module:

Declare Function WritePrivateProfileStringA Lib "kernel32" _
(ByVal SectionStr As String, ByVal ItemName As String, _
ByVal Str2Write As String, ByVal IniFileName As String) As Boolean

Although you probably know the path to Windows\system, for portability it's
a good idea to have finding it be automatic. So include this API
declaration too:

Public Declare Function GetSystemDirectory Lib "kernel32" Alias _
"GetSystemDirectoryA" (ByVal lpBuffer As String, ByVal nSize As Long) As
Long

Include this module level variable to hold the path to the INI file:

Dim PDF_INIPath As String

Now before doing any printing run this to set things up:

Sub InitAutoPDF()
SetINIPath ''Set INI path/name variable
SetPDF_INI_Mode "Auto" ''Write entry to INI to put PDF driver in Auto
mode
End Sub

Now in your main file opening/printing macro your must set the name for the
PDF file to be created as each XLS is printed. This one uses the same name
as the source Excel file but with the extension PDF instead of XLS:

Sub MainPrintRoutine()
Dim WriteFile as String, FileLen as Integer
''Need a loop that opens each XLS and
'' puts its name in the variable WriteFile, and
'' the length of its file name in the variable FileLen
'' Then call this to set name in INI file
WritePDFFileName2Ini Left(WriteFile, FileLen - 3) & "pdf"
End Sub

When you're done run this sub to erase the last file name written to the INI
file and to put the PDF driver back in prompting mode:

Sub ResetManualPDF()
WritePDFFileName2Ini ""
SetPDF_INI_Mode "Prompt"
End Sub

And add these supporting subs called from above:

''Writes target PDF file name into INI
''This must be called prior to each printout
Sub WritePDFFileName2Ini(FName As String)
WritePrivateProfileStringA "Acrobat PDFWriter", "PDFFileName", FName,
PDF_INIPath
End Sub

''Set "CreatePDFExcelMacroShowDialog" entry in INI to passed setting
''The settings are "Prompt" and "Auto"
Sub SetPDF_INI_Mode(Setting As String)
WritePrivateProfileStringA "Acrobat PDFWriter",
"CreatePDFExcelMacroShowDialog", Setting, PDF_INIPath
End Sub

''Sets variable pointing to PDF INI file
Function SetINIPath() As Boolean
Dim Buff As String * 100
Dim RetVal As Long
RetVal = GetSystemDirectory(Buff, 100)
If RetVal > 0 Then
PDF_INIPath = Left(Buff, RetVal) & "\PDFWritr.ini"
SetINIPath = True
Else
MsgBox "Cannot find the Windows System Directory"
End If
End Function

BTW, I extracted all this from a working module but changed some things
around for clarity. So I may have mis-typed some things but hopefully you
can fix these things up.
 
Back
Top