Link to home
Start Free TrialLog in
Avatar of cmagusin
cmagusin

asked on

Excel Doc to PDF in VB Dll

This is the code that works in a VB project.  I moved the code to a DLL and it hangs up on the postscript printing.  Any Ideas?

Dim xlApp As Excel.Application
Dim xlWb As Excel.Workbook
Dim xlWs As Excel.Worksheet

Set xlApp = New Excel.Application
xlApp.Visible = False
xlApp.ScreenUpdating = False
'xlApp.ActivePrinter = "Adobe PDF"  this doesn't work

Set xlWb = xlApp.Workbooks.Open("C:\Inetpub\wwwroot\Attorney Assignments\\DFOC.xls")
Set xlWs = xlWb.Worksheets("HC Notice")

'Print it to a PostScript file using Distiller
' this is were I am having problems... the file starts to create but hangs up
xlWs.PrintOut , , , , "Adobe PDF", True, , "C:\TEST.PS"
xlWb.Close
xlApp.Quit
Set xlWs = Nothing
Set xlWb = Nothing
Set xlApp = Nothing

 'Now call distiller to convert the postscript file to PDF
Dim acr As New ACRODISTXLib.PdfDistiller
acr.bShowWindow = False
acr.FileToPDF "c:\test.ps", "C:\pdfdoc.pdf", ""
Set acr = Nothing
'Delete the old PS file
Kill "c:\test.ps"
'Done
ASKER CERTIFIED SOLUTION
Avatar of fritz_the_blank
fritz_the_blank
Flag of United States of America image

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial