Universal Document Converter
Product Overview
Download
Purchase
Tutorials
Developer Solutions
Support Service
About fCoder Group


      Site search
   


      Video tutorial
Show tutorial


Main page>Developer Solutions>Popular Applications as COM-servers

Print Microsoft Excel Spreadsheet to Image Using Visual Basic 6.0


Universal Document Converter is virtual printer software that saves any document you print as an image file. Below is a source code example that can help you to accomplish your task with Universal Document Converter. Please let us know if you cannot find the solution you need.

' Microsoft Excel 97 or above and Universal Document Converter
' should be installed on your PC and Microsoft Excel should be activated.

Private Sub PrintExcelFile(strFilePath As String, nSheet As Long)

' Run Microsoft Excel as COM-server
  On Error Resume Next
  Dim App As Object
  Dim Book As Object
  Dim Worksheet As Object

  Set App = CreateObject("Excel.Application")

' Open spreadsheet from file
  Err = 0 ' Clear GetLastError() value
  Set Book = App.Workbooks.Open(strFilePath, , True)

  If Err = 0 Then

  ' Select worksheet you want to print
    Set Worksheet = App.Worksheets(nSheet)
    If Err = 0 Then

    ' Print selected worksheet
      Call Worksheet.PrintOut(,,,,"Universal Document Converter")

    End If

  ' Close the spreadsheet
    Call Book.Close
    Set Book = Nothing

  End If

' Close Microsoft Excel
  Call App.Quit
  Set App = Nothing

End Sub



Related topics
Popular pages
Popular solutions


© 2001-2009 fCoder Group, Inc. About fCoder Group | Privacy Policy | Site Map