Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Westi on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Checking status of all checkboxes in a document 1

Status
Not open for further replies.

nochoice

Programmer
Jun 17, 2003
72
CA
I have a WORD doc that has several checkboxes and a button. I change the number of checkboxes on the page often (add/remove).

When the button is pressed, a macro opens a file associated with every checkbox using this form:

if CB1 then
Documents.Open FileName:="c:\mydirectory\" + CB1.Caption
end if

if CB2 then
Documents.Open FileName:="c:\mydirectory\" + CB1.Caption
end if

Checkboxes are named CB1, CB2, CB3.....

How can I have the macro go through the document and open every file associated with a checked checkbox without having to constantly alter my script (one day I'll have boxes 1-10 another I'll have 1-3, 9-12, another I'll have 1-5,9,143, etc....)?
 
As far as I know it's a Toolbox checkbox. I just added the checkbox usin the toolbars (the checkbox is in the document not in a form).
 
There are 2 toolbars -- one called Forms and the other called Control Toolbox. I am assuming that you are using the latter...
Code:
    Dim sh As InlineShape
    For Each sh In ActiveDocument.InlineShapes
        If sh.Type = 5 Then
            If Left(sh.OLEFormat.Object.Name, 2) = "CB" Then
                MsgBox sh.OLEFormat.Object.Caption
            End If
        End If
    Next
Hope this helps :)

Skip,
Skip@TheOfficeExperts.com
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top