Add Reference By GUID

E

emel

I'm writing macros that require a reference from Visio to Excel. Some of the
people that run the macro have Excel 2002, some have 2003. The reference
that I've assigned using Tools / References doesn't work for PCs with Excel
2002 until they manually fiddle with Tools / References on their machines.

Toward the goal of fixing this automatically, I've discovered how to track
down the references in use by a project (code sample below). I've discovered
references.addfromfile and .addfromguid. But, I prefer not to count on
knowing where other folks have installed Excel, so .addfromguid looks like
the better choice.

But, is there a way to determine a GUID programmatically on some arbitrary,
other machine? Extra points if I can specify a major and minor version to
look for. I tried .adddfromfile "Excel.exe" but had no luck.

Thanks!
Ed

This is related to the question I posted as a reply to an old thread here:
http://www.microsoft.com/office/com...ming&mid=9a00889b-d098-4bfa-9971-8c6c3927dfe9

code sample, as promised:

Sub test473()
Dim d As Visio.Document
For Each d In Documents
Debug.Print d.Name
Debug.Print d.Type
If d.Type = visTypeStencil Then
Debug.Print "Project " & d.VBProject.Name
Dim r As VBIDE.Reference
For Each r In d.VBProject.References
Debug.Print r.GUID, r.Name, r.Major, r.Minor, r.IsBroken
Next r
End If
Next d
End Sub
 
E

emel

Hmmm ... looks like I can brute force my through it with:

dim a as object
dim p as string

set a = createobject("excel.application")
p = a.path & "\excel.exe"
d.vbproject.references.addfromfile p ' where d is a visTypeStencil document

and voila! Of course, a little error checking, version checking, and making
sure that the supplied excel reference is broken in the first place will go a
long way on this one.

Now to get my Excel 10 colleagues to run a few tests on their machines.

Ed
 

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