access to the visio object model from a VB add-on

L

LudgerGoeke

I try to access the visio object model from a VB add-on but when I use
source code like

Dim app As Visio.Application
Set app = GetObject(, "Visio.Application")
MsgBox " Application name "+app.Name

I get the following error mesage
" object creation through Active X component is not possible"

I'm using the VBVSL_Adapter from the book "Visio 2003 Developers survival
pack"

Can anyone help me?

Regards
Ludger Goeke
 
J

JuneTheSecond

I thought you are sure that visio is already started.
I tested to start from visio a "test.exe" by shell comand, and
a simple addin like your code.
Each worked well.
 
A

Al Edlund

you might try something like this,
al


Public Sub VisioOpenApplication()
Dim visApp As Visio.Application 'Visio Application Object
Dim visDoc As Visio.Document 'Visio Document Object

'Get the open instance of Visio
set visApp = GetObject(, "Visio.Application")

If (visApp Is Nothing) Then
'there is no open instance of Visio, Create one
set visApp = CreateObject("Visio.Application")
'Add a new blank drawing page
set visDoc = visApp.Documents.Add("")
Else
'There was an open instance of Visio
If visApp.Documents.Count = 0 Then
'if there are no open documents in this instance of
Visio,
'Add a new blank drawing
set visDoc = visApp.Documents.Add("")
Else
'otherwise, get the currently active document
set visDoc = visApp.ActiveDocument
End If
End If


End Sub
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top