Solved

Excel to PDF in VB project

Posted on 2004-09-09
6
230 Views
Last Modified: 2013-12-02
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
0
Comment
Question by:cmagusin
  • 2
6 Comments
 
LVL 7

Expert Comment

by:_agj_
ID: 12024274
no idea why it should fail from a dll, but it seems u can directly print using the distiller.

check this:
http://embedded.eecs.berkeley.edu/video/powerpoint.htm

(this is about powerpt printing to pdf...but cant be different)
0
 
LVL 7

Accepted Solution

by:
_agj_ earned 500 total points
ID: 12024282
this is more specific stuff....but its got a lot of unrequired code:

http://www.igetit.net/SampleCode/Excel_To_PDF_vba_code.htm
0
 

Author Comment

by:cmagusin
ID: 12704848
Thanks
0

Featured Post

Efficient way to get backups off site to Azure

This user guide provides instructions on how to deploy and configure both a StoneFly Scale Out NAS Enterprise Cloud Drive virtual machine and Veeam Cloud Connect in the Microsoft Azure Cloud.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Suggested Solutions

Title # Comments Views Activity
Visual Basic Excel Formatting error 4 107
SLMGR Switches Are Not Working On KMS Host 3 94
Zip Folders Using Chilkat Routines 1 41
How to read File Date Created using VB6 8 39
This article describes some techniques which will make your VBA or Visual Basic Classic code easier to understand and maintain, whether by you, your replacement, or another Experts-Exchange expert.
PaperPort has a feature called the "Send To Bar". It provides a convenient, drag-and-drop interface for using other installed software, such as Microsoft Office. However, this article shows that the latest Office 2016 apps (installed with an Office …
In this first video of the three-part Xpdf series, we introduce and describe Xpdf, a library containing nine command line utilities that perform various functions on PDF files. We show where the library is located and how to download it, discuss its…
In this sixth video of the Xpdf series, we discuss and demonstrate the PDFtoPNG utility, which converts a multi-page PDF file to separate color, grayscale, or monochrome PNG files, creating one PNG file for each page in the PDF. It does this via a c…

803 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question