PC Review


Reply
Thread Tools Rating: Thread Rating: 1 votes, 5.00 average.

PDF the Excel Report

 
 
chithirala@gmail.com
Guest
Posts: n/a
 
      31st Aug 2012
I have an excel report that I wanted to PDF through the VBA code. But the file size is around 230KB if I PDF the report through the VBA code. If I manually PDF the document, file size is like 120 KB. Pls help me what do I need to fix in the below VBA code to PDF the report to smallest file size.

ActiveSheet.ExportAsFixedFormat Type:=xlTypePDF, Filename:= _
"C:\Documents and Settings\archith\Desktop\Club Profile\" & ClubNumber & ".pdf", Quality:= _
xlQualityMinimum, IncludeDocProperties:=True, IgnorePrintAreas:=False, _
OpenAfterPublish:=False



 
Reply With Quote
 
 
 
 
isabelle
Guest
Posts: n/a
 
      1st Sep 2012
hi,

'You must add référence to PDFCreator

Private Declare Sub Sleep Lib "kernel32" (ByVal dwMilliseconds As Long)

Private Const maxTime = 10 ' en secondes
Private Const sleepTime = 250 ' en millisecondes

Sub TestPDF() 'http://grenier.self-access.com/
Dim sPath As String, sFileName As String
sPath = "C:\" '--------------------adapt
sFileName = "test " & Now & " .pdf" '--------------------adapt
SaveAsPDF sFileName, sPath
End Sub

Public Sub SaveAsPDF( _
Optional ByVal strPDFName As String = "", _
Optional ByVal strDirectory As String = "")

Dim pdfc As PDFCreator.clsPDFCreator
Dim DefaultPrinter As String
Dim c As Long
Dim OutputFilename As String

Set pdfc = New clsPDFCreator

With pdfc
.cStart "/NoProcessingAtStartup"
.cOption("UseAutosave") = 1
.cOption("UseAutosaveDirectory") = 1

If strDirectory = "" Then
strDirectory = Environ("USERPROFILE") & "\Mes documents\"
End If
.cOption("AutosaveDirectory") = strDirectory

.cOption("AutosaveFilename") = _
IIf(strPDFName = "", ActiveWorkbook.Name, strPDFName)

.cOption("AutosaveFormat") = 0

DefaultPrinter = .cDefaultPrinter
.cDefaultPrinter = "PDFCreator"
.cClearCache

ActiveWindow.SelectedSheets.PrintOut Copies:=1, Collate:=True

.cPrinterStop = False
End With

c = 0
Do While (pdfc.cOutputFilename = "") And (c < (maxTime * 1000 / sleepTime))
c = c + 1
Sleep 200
Loop

OutputFilename = pdfc.cOutputFilename

With pdfc
.cDefaultPrinter = DefaultPrinter
Sleep 200
.cClose
End With

Sleep 2000

If OutputFilename = "" Then
MsgBox "Création du fichier PDF." & vbCrLf & vbCrLf & _
"Une erreur s'est produite : temps écoulé !", vbExclamation + vbSystemModal
End If
End Sub


--
isabelle



Le 2012-08-31 10:29, (E-Mail Removed) a écrit :
> I have an excel report that I wanted to PDF through the VBA code. But the file size is around 230KB


if I PDF the report through the VBA code. If I manually PDF the document, file size is like 120 KB.

Pls help me what do I need to fix in the below VBA code to PDF the report to smallest file size.
>
> ActiveSheet.ExportAsFixedFormat Type:=xlTypePDF, Filename:= _
> "C:\Documents and Settings\archith\Desktop\Club Profile\" & ClubNumber & ".pdf", Quality:= _
> xlQualityMinimum, IncludeDocProperties:=True, IgnorePrintAreas:=False, _
> OpenAfterPublish:=False
>
>
>

 
Reply With Quote
 
 
 
 
chithirala@gmail.com
Guest
Posts: n/a
 
      4th Sep 2012
On Friday, August 31, 2012 9:29:54 AM UTC-5, chith...@gmail.com wrote:
> I have an excel report that I wanted to PDF through the VBA code. But thefile size is around 230KB if I PDF the report through the VBA code. If I manually PDF the document, file size is like 120 KB. Pls help me what do I need to fix in the below VBA code to PDF the report to smallest file size. ActiveSheet.ExportAsFixedFormat Type:=xlTypePDF, Filename:= _ "C:\Documents and Settings\archith\Desktop\Club Profile\" & ClubNumber & ".pdf", Quality:= _ xlQualityMinimum, IncludeDocProperties:=True, IgnorePrintAreas:=False, _ OpenAfterPublish:=False


Hi,
Thank you very much for the response.
I tested the code, but getting the user defined Type not defined error message in this line.

Dim pdfc As PDFCreator.clsPDFCreator

Do I need to add any of the library?

Thanks,
Anu
 
Reply With Quote
 
isabelle
Guest
Posts: n/a
 
      4th Sep 2012
yes, you must add référence to PDFCreator

http://www.pdfforge.org/download


--
isabelle



Le 2012-09-04 08:00, (E-Mail Removed) a écrit :

> Hi,
> Thank you very much for the response.
> I tested the code, but getting the user defined Type not defined error message in this line.
>
> Dim pdfc As PDFCreator.clsPDFCreator
>
> Do I need to add any of the library?
>
> Thanks,
> Anu
>

 
Reply With Quote
 
 
 
Reply

Thread Tools
Rate This Thread
Rate This Thread:

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
Saving Excel 2007 as PDF - the PDF looks different from the Excel britteva Microsoft Excel Misc 2 22nd Jan 2009 03:09 PM
Report conversion to pdf - lines missing in pdf Mike.Wolowicz@gov.bc.ca Microsoft Access Reports 1 30th Jan 2007 05:07 AM
print PDF file from Excel - NOT print Excel to PDF? Alan Ibbotson Microsoft Excel Programming 1 28th Dec 2006 05:03 AM
Output report to PDF with a default pdf file name FA Microsoft Access Form Coding 1 9th Apr 2006 03:22 AM
Report to PDF without PDF or EPS Printer Dieter Liessmann Microsoft Access Reports 41 9th Nov 2005 01:40 PM


Features
 

Advertising
 

Newsgroups
 


All times are GMT +1. The time now is 05:12 PM.