Access Module Reference to VISIO Library

G

Gary Shell

I have an Access app that generates Visio diagrams. I have Visio 2003 on my
development machine and set a reference in the Access app to the VISIO 2003
library.

When I moved the app to a machine with VISIO 2000 I got errors because of
the reference to the non-existent Visio 2003 libraries on the test machine.
If I changed the reference to the VISIO 2000 library everything worked fine.

My question is how to set up the reference so that when I deploy the app it
is able to determine the environment it finds itself in and change
accordingly.

Gary
 
P

Paul Overway

Instead of setting a reference, use late binding. Late binding allows you
to deploy an application to a PC that may not have one the application
dependencies installed, or may have an older version. It will also allow
you to degrade your application gracefully, if the required dependency is
not installed. When using late binding, you'll use CreateObject to
instantiate the desired object, i.e.,

Dim x As Object

On error resume next

Set x = CreateObject("Visio.Application")

If err.number = 429 Then
Msgbox "Visio is not installed on your PC."
Exit Sub
End If

x.Open "c:\somefile.vsd"

Note that when using late binding, you won't have Intellisense or any
application constants. You either have to know the object model very well,
or you can set a reference, write code, and then change to late binding when
coding is complete.
 
G

Gary Shell

Thanks Paul. I'll try that out. I especially like the tip about waiting to
change this from early to late binding until after code is complete so as to
have intellisense still active during development.

Gary
 

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