Checkboxes in a table

L

Laura

Can anyone help here?

This is a Word 2000 document. It contains a 3-column, 101-row table,
with the first row being the header. Every cell in column 1 except
the header has a checkbox, which I created with the Control Toolbox.

I want to be able to cycle through the table's rows, getting the name
and true/false value from each checkbox, and inserting those results
into the corresponding cells in columns 2 and 3. (Never mind that it
isn't very useful at this point. I'm still at the debugging stage,
and once I get this figured out, it will serve as a foundation for the
final document.)

I can access the individual rows, columns, and cells, and I can access
the individual checkboxes directly. But I can't figure out how to
access the checkboxes THROUGH THE TABLE, and that's the key!

Any ideas?

Thanks,
Laura
 
J

Jay Freedman

Hi, Laura,

This seems to work, although I'm not guaranteeing anything. :)

Dim oTbl As Table
Dim oCell As Cell
Dim oCB As InlineShape
Set oTbl = ActiveDocument.Tables(1)
For Each oCell In oTbl.Columns(1).Cells
If oCell.Range.InlineShapes.Count Then
Set oCB = oCell.Range.InlineShapes(1)
If oCB.Type = wdInlineShapeOLEControlObject Then
If oCB.OLEFormat.ClassType = "Forms.CheckBox.1" Then
MsgBox oCB.OLEFormat.Object.Name & " = " & _
oCB.OLEFormat.Object.Value
End If
End If
End If
Next oCell
 
L

Laura

Thanks.

I ran into access problems with this code -- something about the cells
in the columns being different sizes. But I was able to convert this
to approach the table by rows instead of columns, and that worked. I
was finally able to accomplish what I was trying to do.

Now, would anyone have any idea why the text from plain table cells
comes out with extra ASCII control characters attached? For example,
when I used

strMsg = ActiveDocument.Tables(1).Range.Text

to capture the contents of a table cell, which read "Test message.",
into a string variable, it came out with two 0x07's at the end.

Laura
 
W

Word Heretic

G'day Laura <[email protected]>,

one end of para mark, one end of cell mark

Word implements tables more or less like html.

Steve Hudson - Word Heretic
Want a hyperlinked index? S/W R&D? See WordHeretic.com

steve from wordheretic.com (Email replies require payment)


Laura reckoned:
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top