mdnuts
Registered User.
- Local time
- Today, 12:51
- Joined
- May 28, 2014
- Messages
- 131
my VBA dynamically writes several tables depending on criteria and works quite well.
For example here is adding a row, formatting it and advancing to the next row.
I do it in this manner because I just don't know how many rows any given table is - so I create the rows as I need them, might be clumsy but it works.
What I need to do is add a check-able checkbox to rows with text like this.
[FONT="]
[FONT="]I've trie[/FONT][/FONT][FONT="][FONT="]d several ways that just don't [FONT="]seem[FONT="] to work. [FONT="]as far as I can tell it's because i'm not creating the table then selecting it. I've tried [FONT="]recording a macro and that just shows the bit about selection first.
[FONT="]Here's what I've got[FONT="], it pops an error.
[/FONT][/FONT][/FONT][/FONT][/FONT][/FONT][/FONT][/FONT]
[FONT="][FONT="][FONT="][FONT="][FONT="][FONT="][FONT="][FONT="]
[/FONT][/FONT][/FONT]
[FONT="]I get "requested member of the collection doesn't exist.
[FONT="]If I try to put it on two lines it will just over[FONT="]write cell 1. with the checkbox and I can't seem to position it to the end of the cell first. Any ideas?
[/FONT][/FONT][/FONT]
[/FONT][/FONT][/FONT][/FONT]
[/FONT]
For example here is adding a row, formatting it and advancing to the next row.
Code:
oDoc.Tables(t).Rows.Add 'add a row below control number
oDoc.Tables(t).Rows(i).Range.ParagraphFormat.Alignment = wdAlignParagraphCenter
oDoc.Tables(t).Rows(i).Shading.BackgroundPatternColor = oTableHeaderColor
i = i + 1 'advance to row below control number row.
oDoc.Tables(t).Cell(i, 2).Range.Text = "Check Definition"
What I need to do is add a check-able checkbox to rows with text like this.
[FONT="]
[/FONT][FONT="]Planned: ☐
[FONT="]I've trie[/FONT][/FONT][FONT="][FONT="]d several ways that just don't [FONT="]seem[FONT="] to work. [FONT="]as far as I can tell it's because i'm not creating the table then selecting it. I've tried [FONT="]recording a macro and that just shows the bit about selection first.
[FONT="]Here's what I've got[FONT="], it pops an error.
[/FONT][/FONT][/FONT][/FONT][/FONT][/FONT][/FONT][/FONT]
Code:
oDoc.Tables(t).Cell(i, 2).Range.Text = "Planned: " & oDoc.Tables(t).Cell(i, 1).Range.ContentControls.Add(wdContentControlCheckBox)
[/FONT][/FONT][/FONT]
[FONT="]I get "requested member of the collection doesn't exist.
[FONT="]If I try to put it on two lines it will just over[FONT="]write cell 1. with the checkbox and I can't seem to position it to the end of the cell first. Any ideas?
[/FONT][/FONT][/FONT]
[/FONT][/FONT][/FONT][/FONT]
[/FONT]