View Full Version : Visio Search
maestro_01
01-24-2010, 08:24 PM
Hello All,
I am trying to open a Visio document via an Access form > this is the easy part.
I would like to be able to link to objects on the Visio diagram, depending on the form that is being viewed.
Is it possible to search the Visio Diagram using the text in the objects?  How would I go about this in VBA?
Thanks,
Maestro
maestro_01
03-26-2010, 12:40 PM
Okay, basically what I do, is open the Visio document and do a loop through all the shapes to find where the selected text (via access form) is and format accordingly.
Private Sub ReferVisio_Click()
Dim appVisio As Visio.Application
Dim cbo As Access.ComboBox
Dim vsoCharacters1 As Visio.Characters
Dim docs As Visio.Documents
Dim doc As Visio.Document
Dim vsoShape1 As Visio.Shape
Dim path As String
Dim vsoToolbars As Visio.Toolbars
Dim vsoToolbar As Visio.Toolbar
'path to sharepoint
path = "filepath"
'Open Visio
Set appVisio = GetObject("", "Visio.Application")
'Open file via sharepoint
    Set docs = appVisio.Documents
        docs.Add path
    Set doc = appVisio.ActiveDocument
'Defined counter to search shapes in the diagram
        Dim x As Long
        x = 1
        Do
        Do While x < 300
        x = x + 1
        On Error Resume Next
        'Sets vsoCharacters1 to shape text
        Set vsoCharacters1 = appVisio.ActivePage.Shapes.ItemFromID(x).Characters
        Set vsoShape1 = appVisio.ActivePage.Shapes.ItemFromID(x)
        'Searches shapes on page via count
            If vsoCharacters1 = attributeName Then
                    vsoShape1.LineStyle = "Highlight"
            Exit Do
            End If
        'Loops through page shapes until Sub Capability is found within shape text
        Loop
        Loop Until vsoCharacters1 <> attributeName
'Formats the page view
appVisio.Settings.ShowShapeSearchPane = False
appVisio.ActiveWindow.ViewFit = visFitPage
appVisio.ActiveWindow.Windows.ItemFromID(visWinIDPanZoom).Visible = True
appVisio.ShowToolbar = False
appVisio.Visible = True
End Sub
Powered by vBulletin® Version 4.2.5 Copyright © 2025 vBulletin Solutions Inc. All rights reserved.