Microsoft Office Forums

Go Back   Microsoft Office Forums > >

Reply
 
Thread Tools Display Modes
  #1  
Old 06-17-2019, 05:50 PM
Shan Shan is offline Selecting particular Object types with VBA Windows 10 Selecting particular Object types with VBA Office 2016
Novice
Selecting particular Object types with VBA
 
Join Date: Jun 2019
Posts: 1
Shan is on a distinguished road
Default Selecting particular Object types with VBA

Hi all,



I am trying to select a particular object type in Visio. I have got some code that seems to do this however when I select the object I want / Which is a cube box kind of graphic(still a shape from the standard templates), it does not work.

Any ideas to what I am doing wrong with my code?

Code:
 
Sub SelectSimilarShapesByMaster()
    If ActiveWindow.Selection.Count = 0 Then Exit Sub
    Dim SelShp As Visio.Shape
    Set SelShp = ActiveWindow.Selection(1)
    If SelShp.Master Is Nothing Then Exit Sub
    ActiveWindow.DeselectAll
    Dim CheckShp As Visio.Shape
    For Each CheckShp In ActivePage.Shapes
        If Not CheckShp.Master Is Nothing Then
            If CheckShp.Master = SelShp.Master Then
                ActiveWindow.Select CheckShp, visSelect
            End If
        End If
    Next CheckShp
End Sub

Thanks
Reply With Quote
  #2  
Old 06-26-2019, 04:35 PM
Guessed's Avatar
Guessed Guessed is offline Selecting particular Object types with VBA Windows 10 Selecting particular Object types with VBA Office 2016
Expert
 
Join Date: Mar 2010
Location: Canberra/Melbourne Australia
Posts: 3,932
Guessed has a brilliant futureGuessed has a brilliant futureGuessed has a brilliant futureGuessed has a brilliant futureGuessed has a brilliant futureGuessed has a brilliant futureGuessed has a brilliant futureGuessed has a brilliant futureGuessed has a brilliant futureGuessed has a brilliant futureGuessed has a brilliant future
Default

Your code works fine on my machine. I don't know what is going wrong on your machine. Perhaps a reboot is in order.

Maybe you could try including a debug.print statement to find out what masters it is trying to match with
Code:
Sub SelectSimilarShapesByMaster()
  Dim SelShp As Visio.Shape, CheckShp As Visio.Shape
  If ActiveWindow.Selection.Count > 0 Then
    Set SelShp = ActiveWindow.Selection(1)
    If SelShp.Master Is Nothing Then Exit Sub
    For Each CheckShp In ActivePage.Shapes
      If Not CheckShp.Master Is Nothing Then
        Debug.Print SelShp.Master, CheckShp.Master
        If CheckShp.Master = SelShp.Master Then
          ActiveWindow.Select CheckShp, visSelect
        End If
      End If
    Next CheckShp
  End If
End Sub
__________________
Andrew Lockton
Chrysalis Design, Melbourne Australia
Reply With Quote
Reply

Thread Tools
Display Modes


Similar Threads
Thread Thread Starter Forum Replies Last Post
I have Error at File System Object: Cant find object or lib johndrew Word VBA 3 07-05-2018 08:46 PM
Organization Chart Object Changes to Equation Object? jhcoleman53 Drawing and Graphics 0 08-24-2017 07:09 AM
Selecting particular Object types with VBA Selecting and deleting all Object Anchors jeffreybrown Word VBA 2 05-06-2016 04:27 AM
Selecting particular Object types with VBA Insert Object into Word Document only appears as Icon, without selecting display as Icon Simy Word 1 04-30-2015 12:47 PM
Problem: object library invalid or contains references to object definitions aligahk06 Office 0 08-19-2010 12:29 PM

Other Forums: Access Forums

All times are GMT -7. The time now is 02:53 PM.


Powered by vBulletin® Version 3.8.11
Copyright ©2000 - 2024, vBulletin Solutions Inc.
Search Engine Optimisation provided by DragonByte SEO (Lite) - vBulletin Mods & Addons Copyright © 2024 DragonByte Technologies Ltd.
MSOfficeForums.com is not affiliated with Microsoft