create pdf from excel etc. visual basic 6.0

Reply

Join Date: Jul 2007
Posts: 2
Reputation: sayyad786i is an unknown quantity at this point 
Solved Threads: 0
sayyad786i sayyad786i is offline Offline
Newbie Poster

create pdf from excel etc. visual basic 6.0

 
0
  #1
Jul 8th, 2007
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.
Reply With Quote Quick reply to this message  
Join Date: Jun 2007
Posts: 95
Reputation: manoshailu is an unknown quantity at this point 
Solved Threads: 9
manoshailu's Avatar
manoshailu manoshailu is offline Offline
Junior Poster in Training

Re: create pdf from excel etc. visual basic 6.0

 
0
  #2
Jul 9th, 2007
hi,

try the below coding.
Visual Basic 4 / 5 / 6 Syntax (Toggle Plain Text)
  1. Public Function ConvertFile(strSourceFileName As String) As Boolean
  2. On Error GoTo ErrorHandler
  3.  
  4. Dim msExcel As Excel.Application
  5. Set msExcel = GetObject(Class:="Excel.Application")
  6.  
  7. Dim p As String
  8. p = "Acrobat Distiller on Ne00:"
  9.  
  10. msExcel.Visible = False
  11. msExcel.Workbooks.Open strSourceFileName
  12. strMenuFilePs = strSourceFileName
  13. msExcel.ActiveWorkbook.PrintOut ActivePrinter:=p, PrintToFile:=False, PrToFileName:=strMenuFilePs
  14. strMenuFilePDF = "c:\try.pdf"
  15. Dim myPDF As PdfDistiller
  16. Set myPDF = New PdfDistiller
  17. myPDF.FileToPDF strMenuFilePs, strMenuFilePDF, ""
  18. Set myPDF = Nothing
  19. msExcel.ActiveWorkbook.Close False
  20.  
  21. ' Should check and quit excel when done
  22. msExcel.Quit
  23. Set msExcel = Nothing
  24. ConvertFile = True
  25. Exit Function
  26.  
  27. ErrorHandler:
  28. ' Create Excel for the first time if it is not active
  29. If Err.Number = 429 Then
  30. Set msExcel = CreateObject("Excel.Application")
  31. Err.Clear ' Clear Err object in case error occurred.
  32. Resume
  33. End If
  34.  
  35. ' All other errors handled here
  36. If IsCriticalError Then
  37. ConvertFile = False
  38. Exit Function
  39. Else
  40. Resume
  41. End If
  42. End Function
best regards
shailu
Last edited by cscgal; Sep 2nd, 2008 at 10:46 pm. Reason: Added code tags
Reply With Quote Quick reply to this message  
Join Date: Sep 2008
Posts: 3
Reputation: mason_bancroft is an unknown quantity at this point 
Solved Threads: 0
mason_bancroft mason_bancroft is offline Offline
Newbie Poster

Re: create pdf from excel etc. visual basic 6.0

 
0
  #3
Sep 2nd, 2008
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!
Visual Basic 4 / 5 / 6 Syntax (Toggle Plain Text)
  1. Sub Separate()
  2. Dim s as String, sh as worksheet
  3. For Each sh In ThisWorkbook.Worksheets
  4. If sh.Visible Then 'ignores hidden sheets
  5. sh.Copy
  6. s = "c:\Separated Sheets\" & sh.Name 'location and names of workbooks
  7. ActiveWorkbook.SaveAs Filename:=s
  8. Range("A1:IV5000").Copy 'selects all cells
  9. Range("A1").PasteSpecial Paste:=xlPasteValues 'pastes values only
  10. Application.CutCopyMode = False
  11. Range("A1").Select 'this is just to take the cursor
  12. 'back to the top to make that sheet a litte "cleaner"
  13. ActiveWorkbook.Close SaveChanges:=True
  14. End If
  15. Next sh
  16. End Sub
Last edited by cscgal; Sep 2nd, 2008 at 10:46 pm. Reason: Simplify code
Reply With Quote Quick reply to this message  
Reply

This thread is more than three months old.
Perhaps start a new thread instead?
Message:



Similar Threads
Other Threads in the Visual Basic 4 / 5 / 6 Forum
Thread Tools Search this Thread



About Us | Contact Us | Advertise | DaniWeb | Acceptable Use Policy | RSS Feed

©2003 - 2009 DaniWeb® LLC