Author Topic: Finding all checkboxes and setting each to be unchecked  (Read 107 times)

0 Members and 1 Guest are viewing this topic.


  • Newbie
  • *
  • Posts: 1
Finding all checkboxes and setting each to be unchecked
« on: June 17, 2020, 12:40:54 PM »
Hi. I have searched everywhere for this and can't seem to find an answer. I know the big problem is I don't really understand how OLEObjects, namely CheckBoxes, work in vba for this particular thing I want to do.

I want to create a macro I can run when my Visio document is opened which goes through the document, finds each checkbox and sets it to unchecked. I have tried various for/each loops, and most of them do not throw an error, but the checkboxes do not change to unchecked. I have a similar macro which finds all the layers in a doc which meet specific name criteria, and makes them invisible. The checkboxes are set up to make each of those layers visible on demand. All that works perfectly; however, when the document is closed and then reopened, whatever state the checkboxes were in at the time of closing is the state they are in when the document reopens. Since this document will be used for training, I really need the checkboxes to start in an unchecked state.

Can someone help me with code that will 1) search the document for checkboxes, and 2) upon finding each one, change it to unchecked state?

thanks in advance for your help!


Post Post: nevermind; found it. Thanks!
« Last Edit: June 17, 2020, 12:55:57 PM by SandiSCE »


  • Hero Member
  • *****
  • Posts: 931
    • UnmanagedVisio
Re: Finding all checkboxes and setting each to be unchecked
« Reply #1 on: June 17, 2020, 02:11:50 PM »
You could try the following code (add it to "ThisDocument"):
Private Sub Document_DocumentOpened(ByVal doc As IVDocument)
    For Each o In ActiveDocument.OLEObjects
        o.Object = False
End Sub