Checkbox - Formfield vs InlineShape

S

Sash

Hi,

I have a doc which has around 500 tables. I want to have 3
'checkboxes' in one cell of each of the tables

I created a macro which added 3 InlineShapes OLEcontrol forms checkbox
to all these tables. With this the document bloated by 5MB and takes
10 min to open.

Wanted to explore if I could do the same with formfields and if that
would make it better.

Please help.

Regards,
Sash
 
G

Greg Maxey

Sash,

For adding the formfields you could use something like this:

Sub ScratchMaco()
Dim oTbl As Word.Table
Dim i As Long
For Each oTbl In ThisDocument.Tables
For i = 1 To 3
oTbl.Cell(1, 1).Range.FormFields.Add oTbl.Cell(1, 1).Range,
wdFieldFormCheckBox
Next i
Next oTbl
End Sub

What it will do to file size or performance? I don't know.
 
S

Sash

Hi Greg,

Thanks!

Managed to do some experimentation and get to the same code.

Its not as pretty as OLE control but works. Document size bloated
marginally and is much faster to open.

Any clue on how to position formfields in a cell? Right now they all
come up at the start of the cell.

Cheers,
Sash
 
G

Greg Maxey

Sash,

I suppose you could set up some tabs in the table cell and use something
like:

Sub ScratchMaco()
Dim oTbl As Word.Table
Dim i As Long
For Each oTbl In ThisDocument.Tables
oTbl.Cell(1, 1).Range.Select
With Selection
.Collapse wdCollapseStart
.FormFields.Add Selection.Range, wdFieldFormCheckBox
.TypeText vbTab
.FormFields.Add Selection.Range, wdFieldFormCheckBox
.TypeText vbTab
.FormFields.Add Selection.Range, wdFieldFormCheckBox
End With
Next oTbl
End Sub

Hi Greg,

Thanks!

Managed to do some experimentation and get to the same code.

Its not as pretty as OLE control but works. Document size bloated
marginally and is much faster to open.

Any clue on how to position formfields in a cell? Right now they all
come up at the start of the cell.

Cheers,
Sash
 

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