PC Review


Reply
Thread Tools Rate Thread

Converting Excel worksheet to PDF then print

 
 
kidkarma
Guest
Posts: n/a
 
      27th Feb 2007
Hi,
As subject suggests been tring to convert an excel sheet(with data
validation) to convert to pdf and print each time data changes on the
sheet.

ISSUES:

1)Method 'odist' of object 'cACroDist' failed.

If i step through the code though it continues and appears to work
except for

2)the fact that althougha box appears that shows that it is 'now
printing page 1 of 1', when i go to a printer nothing has actually
printed


Can anyone help me figure this. it's been killing me all day. Is there
another alternative? I';ve looked on the web but the examples seem
more complicated than what i need as I am only dealing with one
worksheet rather than trying to print out sheets in many workbooks

sorry if this hasn't made sense. Please let me know


Sub Print2PDF()

Dim sPSFileName As String 'Name of PS to be created
Dim sPDFFileName As String 'Name of PDF to be created
Dim sJobOptions As String
Dim sCurrentPrinter As String 'Same current printer choice to
resume at end
Dim sPDFVersionAndPort As String 'Version of Adobe
Dim appDist As cACroDist

Set appDist = New cACroDist
sCurrentPrinter = Application.ActivePrinter 'Save the currently
active printer
sPDFVersionAndPort = "Adobe PDF on Ne01:"
sPSFileName = ThisWorkbook.Path & "\MacroData validation" & ".ps"
'Name of PS file
sPDFFileName = ThisWorkbook.Path & "\MacroData validation" &
".pdf" 'Name of PDF
ThisWorkbook.Sheets.PrintOut ActivePrinter:=sPDFVersionAndPort, _
PrintToFile:=True, PrToFileName:=sPSFileName 'Prints to PS

Call appDist.odist.FileToPDF(sPSFileName, sPDFFileName,
sJobOptions)
'Creates PDF

Kill sPSFileName 'Removes PS

Application.ActivePrinter = sCurrentPrinter 'Change back to the
original printer

End Sub

****BELOW is a class module named cACroDist that is also included

Option Explicit

Public WithEvents odist As PdfDistiller

Private Sub Class_Initialize()
Set odist = New PdfDistiller
End Sub



Thanks in advance!

 
Reply With Quote
 
 
 
 
NickHK
Guest
Posts: n/a
 
      27th Feb 2007
You code works for me as written.

Check that appDist is actually being created properly.
Do you get the .ps file created correctly ?

NickHK

"kidkarma" <(E-Mail Removed)> wrote in message
news:(E-Mail Removed)...
> Hi,
> As subject suggests been tring to convert an excel sheet(with data
> validation) to convert to pdf and print each time data changes on the
> sheet.
>
> ISSUES:
>
> 1)Method 'odist' of object 'cACroDist' failed.
>
> If i step through the code though it continues and appears to work
> except for
>
> 2)the fact that althougha box appears that shows that it is 'now
> printing page 1 of 1', when i go to a printer nothing has actually
> printed
>
>
> Can anyone help me figure this. it's been killing me all day. Is there
> another alternative? I';ve looked on the web but the examples seem
> more complicated than what i need as I am only dealing with one
> worksheet rather than trying to print out sheets in many workbooks
>
> sorry if this hasn't made sense. Please let me know
>
>
> Sub Print2PDF()
>
> Dim sPSFileName As String 'Name of PS to be created
> Dim sPDFFileName As String 'Name of PDF to be created
> Dim sJobOptions As String
> Dim sCurrentPrinter As String 'Same current printer choice to
> resume at end
> Dim sPDFVersionAndPort As String 'Version of Adobe
> Dim appDist As cACroDist
>
> Set appDist = New cACroDist
> sCurrentPrinter = Application.ActivePrinter 'Save the currently
> active printer
> sPDFVersionAndPort = "Adobe PDF on Ne01:"
> sPSFileName = ThisWorkbook.Path & "\MacroData validation" & ".ps"
> 'Name of PS file
> sPDFFileName = ThisWorkbook.Path & "\MacroData validation" &
> ".pdf" 'Name of PDF
> ThisWorkbook.Sheets.PrintOut ActivePrinter:=sPDFVersionAndPort, _
> PrintToFile:=True, PrToFileName:=sPSFileName 'Prints to PS
>
> Call appDist.odist.FileToPDF(sPSFileName, sPDFFileName,
> sJobOptions)
> 'Creates PDF
>
> Kill sPSFileName 'Removes PS
>
> Application.ActivePrinter = sCurrentPrinter 'Change back to the
> original printer
>
> End Sub
>
> ****BELOW is a class module named cACroDist that is also included
>
> Option Explicit
>
> Public WithEvents odist As PdfDistiller
>
> Private Sub Class_Initialize()
> Set odist = New PdfDistiller
> End Sub
>
>
>
> Thanks in advance!
>



 
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
Can't save in Hidden Worksheet after converting to Excel Add-In Graff Microsoft Excel Programming 3 5th Jan 2009 03:58 PM
my excel is converting all my print jobs to print to file why? =?Utf-8?B?R2luZ2Vy?= Microsoft Excel Misc 2 10th Apr 2007 01:28 PM
Converting data from a form to an excel worksheet =?Utf-8?B?VGVyZXNhIE5ldmVz?= Microsoft Word Document Management 2 19th Sep 2006 10:13 PM
Converting Excel Worksheet to PDF using VBA Thomas Cox Microsoft Excel Programming 2 11th Aug 2005 12:48 PM
Re: Converting from excel worksheet to CVS JE McGimpsey Microsoft Excel Misc 4 29th Apr 2004 02:08 AM


Features
 

Advertising
 

Newsgroups
 


All times are GMT +1. The time now is 07:19 AM.