Finding all checkboxes and setting each to be unchecked

Started by SandiSCE, June 17, 2020, 05:40:54 PM

Previous topic - Next topic

0 Members and 1 Guest are viewing this topic.

SandiSCE

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!

SandiSCE


Post Post: nevermind; found it. Thanks!

Nikolay

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
    Next
   
End Sub