| sayyad786i | Jul 8th, 2007 3:24 am | |
| create pdf from excel etc. visual basic 6.0 hi,
I want to create a pdf from excel sheet using visual basic 6.0. Can you people help me describing or sending me a ready codes regarding the same.
Thanks with regards,
Sayyad H.A.
India. |
| manoshailu | Jul 9th, 2007 4:57 am | |
| Re: create pdf from excel etc. visual basic 6.0 hi,
try the below coding.
Public Function ConvertFile(strSourceFileName As String) As Boolean
On Error GoTo ErrorHandler
Dim msExcel As Excel.Application
Set msExcel = GetObject(Class:="Excel.Application")
Dim p As String
p = "Acrobat Distiller on Ne00:"
msExcel.Visible = False
msExcel.Workbooks.Open strSourceFileName
strMenuFilePs = strSourceFileName
msExcel.ActiveWorkbook.PrintOut ActivePrinter:=p, PrintToFile:=False, PrToFileName:=strMenuFilePs
strMenuFilePDF = "c:\try.pdf"
Dim myPDF As PdfDistiller
Set myPDF = New PdfDistiller
myPDF.FileToPDF strMenuFilePs, strMenuFilePDF, ""
Set myPDF = Nothing
msExcel.ActiveWorkbook.Close False
' Should check and quit excel when done
msExcel.Quit
Set msExcel = Nothing
ConvertFile = True
Exit Function
ErrorHandler:
' Create Excel for the first time if it is not active
If Err.Number = 429 Then
Set msExcel = CreateObject("Excel.Application")
Err.Clear ' Clear Err object in case error occurred.
Resume
End If
' All other errors handled here
If IsCriticalError Then
ConvertFile = False
Exit Function
Else
Resume
End If
End Function best regards
shailu |
| mason_bancroft | Sep 2nd, 2008 6:50 pm | |
| Re: create pdf from excel etc. visual basic 6.0 I have a VB script which saves worksheets as its own workbook. How could I get it to save it as a pdf? I'm using Adobe Acrobat Professional and its Reference Libraries.
Please help!
Sub Separate()
Dim s as String, sh as worksheet
For Each sh In ThisWorkbook.Worksheets
If sh.Visible Then 'ignores hidden sheets
sh.Copy
s = "c:\Separated Sheets\" & sh.Name 'location and names of workbooks
ActiveWorkbook.SaveAs Filename:=s
Range("A1:IV5000").Copy 'selects all cells
Range("A1").PasteSpecial Paste:=xlPasteValues 'pastes values only
Application.CutCopyMode = False
Range("A1").Select 'this is just to take the cursor
'back to the top to make that sheet a litte "cleaner"
ActiveWorkbook.Close SaveChanges:=True
End If
Next sh
End Sub |
| All times are GMT -4. The time now is 10:07 pm. | |
Forum system based on vBulletin Copyright ©2000 - 2009, Jelsoft Enterprises Ltd.
©2003 - 2009 DaniWeb® LLC