Visio 2003: Problem with early/late binding while placing a shape

A

Alexander Overmann

Hi
I want to launch Vision 2003 and place a shape with VB(A) from MS-Access
2003

I do this:
1. Set reference to Visio 11 Type Library
2. Create a form with this code:
----------CODE
Dim VsoApp As Object
Dim VsoShape As Visio.Shape
Dim obj As Object
Dim VsoActivePage As Object

Set VsoApp = GetObject("", "Visio.Application")
VsoApp.Documents.AddEx "", visMSDefault, 0
VsoApp.Documents.OpenEx "periph_m.vss", visOpenRO + visOpenDocked

Set obj = VsoApp.Documents.Item("PERIPH_M.VSS").Masters.ItemU("Router")
Set VsoActivePage = VsoApp.Activepage
Set VsoShape = VsoActivePage.Drop(obj, 1, 1)

VsoShape.Characters = "Testchar"
VsoShape.NameU = "nameu Test"

VsoApp.Activepage.Layout

VsoApp.Quit
Set VsoApp = Nothing
-----CODE
I have already replace the "Dim ... as <visio datatype>" with OBJECT in
order to change from early binding to late binding.

Currently this code works fine! Now I replace the last line filled with
visio datatype:
Dim VsoShape As Visio.Shape with
Dim VsoShape As Object

and remove the reference to the visio type library.

But now the code wont run any more :( Visio still starts but I got at line
Set VsoShape = VsoActivePage.Drop(obj, 1, 1)

the runtime error 91 (and the german message: Objektvariable oder
With-Blockvariable nicht festgelegt)

Where's the mistake and what can I do? I cannot use early binding as there
are some users who do not have Visio installed. The missing typelibrary will
cause a error each time they start the database. Maybe my code is wrong in
an other line?

Thank you for any help,
Alex
 
C

Chris Roth [ Visio MVP ]

Keine Ahnung,

This isn't much help, but try breaking up the process a bit:

Instead of:

Set VsoShape = VsoActivePage.Drop(obj, 1, 1)

Try perhaps:

VsoActivePage.Drop obj, 1, 1
Set VsoShape = VsoApp.ActiveWindow.Selection(1)

Then we can see if the problem is with the shape or obj...


FYI: Another problem I've seen that might be related is that there is a
problem with German Vis2003 and getting shapes with "Sheet.X". Someone
wrongly translated part of the automation, so Germans have to use "Tabelle"
in code, which is not very universal...

--

Hope this helps,

Chris Roth
Visio MVP
 
A

Alexander Overmann

Hello,

Chris Roth said:
Keine Ahnung,

This isn't much help, but try breaking up the process a bit:

Instead of:

Set VsoShape = VsoActivePage.Drop(obj, 1, 1)

Try perhaps:

VsoActivePage.Drop obj, 1, 1
Set VsoShape = VsoApp.ActiveWindow.Selection(1)

ok, I did it:

Set obj = VsoApp.Documents.Item("PERIPH_M.VSS").Masters.ItemU("Router")

Set VsoActivePage = VsoApp.Activepage
VsoActivePage.Drop obj, 1, 1
Set VsoShape = VsoApp.ActiveWindow.Selection(1)


But now the error still applies at the line
VsoActivePage.Drop obj, 1, 1

Then we can see if the problem is with the shape or obj...
I am not sure what to now.
If I use early binding and change (other code is the same, see below if you
do not have my first posting)
Dim VsoShape As Object
back to
Dim VsoShape As visio.shape

everything works fine.

Any new idea?

Thank you,
Alex
[/QUOTE]
 
A

Alexander Overmann

Hi
meanwhile I have found the solution (see below) by myself.

Just made a new empty.vst and saved it.

And changed the code:
vsoApp.Documents.AddEx "", visMSDefault
vsoApp.Documents.OpenEx "periph_m.vss", visOpenRO + visOpenDocked

to

vsoApp.Documents.AddEx "c:\empty.vst", visMSDefault

and everything works fine; do not know why :)

Nuts :)
 

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