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 strongm on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Visio Object in A2K

Status
Not open for further replies.

TBOB

Technical User
Jun 22, 2002
65
US
I am new to using objects in Access VBA. I want to open a specific Visio drawing from my database based on the value of one of my fields. I can open Visio itself and tell it where to look for the file with the following code:

Dim oApp As Object
Dim stLineNum As String
Dim stLinePath As String

stLineNum = Forms!lines![linenum]
stLinePath = "C:\Drawings\Lines\D” & stLineNum

Set oApp = CreateObject("Visio.Application")
oApp.Visible = True

On Error Resume Next

I’m stuck here because I’m not sure how to tell Visio which file to open. What methods are available for Visio? How do I find out the methods associated with any object?

Thanks,

Tony
 
To find what methods are available for Visio, click on the Object Browser Icon in the Visual Basic Editor and find Visio in the library drop down. If it's not there then you need to create a reference to it. All Libraries is the default. In the list box below you can find all the methods for every object in your project.
Hope that helps.
 
Here's an example:
Code:
Sub RunVisio()

  Dim vapp As Visio.Application
  Dim vdoc As Visio.Document
  Dim shp As Visio.Shape
  
  Set vapp = New Visio.Application
  vapp.Visible = True
  
  Set vdoc = vapp.Documents.Open("C:\VisioTest.vsd")
  
  Set shp = vdoc.Pages(1).DrawRectangle(1, 1, 4, 4)
  
  With shp
    .LineStyle = "Guide"
  End With

End Sub
VBSlammer
redinvader3walking.gif

Unemployed in Houston, Texas
 
Thanks for the input. It put me on track.

Tony
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top