Consulting

Results 1 to 2 of 2

Thread: Visio Search

  1. #1

    Visio Search

    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

  2. #2

    Got it after some time

    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.

    [VBA]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[/VBA]

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •