Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations TouchToneTommy on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

System.InvalidCastException: Visio

Status
Not open for further replies.

mc13

Programmer
May 26, 2000
26
US


I have a VB.net application to produce a Visio drawing dynamiclly using values from a database. The issue is that when an instance of Visio is made I recieve this error.

System.InvalidCastException: QueryInterface for interface Microsoft.Office.Interop.IVApplication failed.

Code:
   Sub fBuildFlowchart() 
      Dim vApp As Application 
      Dim vDoc As Document 
      Dim vFromShape As Shape 
      Dim vToShape As Shape 
      Dim vConnector As Shape 
      Dim vFlowChartMaster As Master 
      Dim vConnectorMaster As Master 
      Dim vStencil As Document 
      Dim dblXLocation As Double 
      Dim dblYLocation As Double 
      Dim vBeginCell As Cell 
      Dim vEndCell As Cell 
      Dim iCount As Integer 
      Const TEMPLATEPATH = "C:\Program Files\Visio\Solutions\Flowchart\Basic Flowchart Shapes.vss" 

      ' Change this constant to match your choice of location and file name. 
      Const SAVENEWFILE = "C:\Simpleflowchart.vsd" 

      ' Start point measured from the bottom left corner. 
      Try 


      dblXLocation = 4.25 
      dblYLocation = 8.5 

         vApp = New Application 


      'Create a new document; note the empty string. 


      Catch ex As Exception 
         MsgBox(ex.Message) 
      End Try 

      Try 
         vDoc = vApp.Documents.Add("") 

FAILS HERE 
         vStencil = vApp.Documents.OpenEx(TEMPLATEPATH, 4) 
      Catch ex As Exception 
         MsgBox(ex.ToString) 
      End Try
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top