| | |
create pdf from excel etc. visual basic 6.0
![]() |
hi,
try the below coding.
best regards
shailu
try the below coding.
Visual Basic 4 / 5 / 6 Syntax (Toggle Plain Text)
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
shailu
Last edited by cscgal; Sep 2nd, 2008 at 10:46 pm. Reason: Added code tags
•
•
Join Date: Sep 2008
Posts: 3
Reputation:
Solved Threads: 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!
Please help!
Visual Basic 4 / 5 / 6 Syntax (Toggle Plain Text)
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
Last edited by cscgal; Sep 2nd, 2008 at 10:46 pm. Reason: Simplify code
![]() |
Similar Threads
- Visual & Excel without referencing Excel??? (Visual Basic 4 / 5 / 6)
- getting data from a text file and putting it in an excel file using visual basic 6.0 (Visual Basic 4 / 5 / 6)
- Open Excel file from Visual Basic (Visual Basic 4 / 5 / 6)
- open a PDF file in visual basic (Visual Basic 4 / 5 / 6)
- Pdf Conversion To Tif Using Visual Basic (Visual Basic 4 / 5 / 6)
- Visual Basic Error on Word and Excel 2003 (Windows NT / 2000 / XP)
- Creating an OS in visual basic 6.0 (Visual Basic 4 / 5 / 6)
Other Threads in the Visual Basic 4 / 5 / 6 Forum
- Previous Thread: 2 dimensional object array
- Next Thread: copy and paste exe files
| Thread Tools | Search this Thread |
* 6 429 2007 access activex add age application basic beginner birth bmp calculator cd cells.find click client code college component connection connectionproblemusingvb6usingoledb copy creat ctrl+f data database datareport date delete dissertations dissertationthesis dissertationtopic edit error excel excelmacro file filename form hardware header iamthwee image inboxinvb internetfiledownload keypress label listbox listview liveperson login looping machine microsoft movingranges number objectinsert open oracle password prime program prompt range-objects readfile reading record refresh remotesqlserverdatabase report save search sendbyte sites sort sql sql2008 sqlserver subroutine tags textbox time urldownloadtofile vb vb6 vb6.0 vba visual visualbasic visualbasic6 web window windows





