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 Visio Drawing 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 Visio 2000 or above and Universal Document Converter
' should be installed on your PC and Microsoft Visio should be activated.

Private Sub PrintVisioDrawing(strFilePath As String)

' Define constants
  Const visOpenRW = &H20
  Const visOpenDontList = &H8
  Const visPrintAll = 0

' Run Microsoft Visio as COM-server
  On Error Resume Next
  Dim App As Object
  Dim Drawing As Object
    
  Set App = CreateObject("Visio.Application")
  App.Visible = False
    
' Open drawing from file
  Err = 0 ' Clear GetLastError() value
  Set Drawing = App.Documents.OpenEx(strFilePath, _
                                           visOpenRW And visOpenDontList)
  
  If Err = 0 Then
    
  ' Change Drawing preferences for scaling it to page
    Drawing.PrintCenteredH = True
    Drawing.PrintCenteredV = True
    Drawing.PrintFitOnPages = True
    
  ' Print drawing
    Drawing.Printer = "Universal Document Converter"
    Drawing.PrintOut(visPrintAll)

  ' Close drawing
    Drawing.Saved = True
    Drawing.Close
    Set Drawing = Nothing
    
  End If
    
' Close Microsoft Visio
  Call App.Quit
  Set App = Nothing

End Sub



Related topics
Popular pages
Popular solutions


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