Any coding out there that would automatically add checkboxes to a table field
if a new line is created?

I have a table that has checkboxes in 3 fields. If the user is on the last
line of the table and tabs, a new line is added as is the way with a Word
table. What I want to do is be abel to have the checkboxes added
automaticallyt.

TIA,

--
Cyberwolf
Finder of Paths, Hunter of Prey
Ghost of the Night, Shadow of Day
The Wolf

Re: add checkbox to table programatically by Helmut

Helmut
Mon Mar 31 06:47:26 PDT 2008

Hi Cyberwolf,

maybe like that:

Sub NextCell()
Dim rTbl As Range
Set rTbl = Selection.Tables(1).Range
' if the selection is in the last cell of a table
If Selection.Cells(1).Range.IsEqual( _
rTbl.Cells(rTbl.Cells.Count).Range) Then
Selection.Rows(1).Range.Copy
Selection.Tables(1).Rows.Add
Selection.Tables(1).Rows.Last.Select
Selection.Paste
Selection.Rows(1).Delete
Selection.MoveUp unit:=wdLine
Else
Selection.Cells(1).Next.Select
Selection.Collapse
End If
End Sub

--

Greetings from Bavaria, Germany

Helmut Weber, MVP WordVBA

Vista Small Business, Office XP

Re: add checkbox to table programatically by Cyberwolf

Cyberwolf
Tue Apr 01 04:41:07 PDT 2008

That was what I was looking for, but I do not want the value of the 1st cell
in the copied range to be copied, or delete it once the range is copied.
Also I want to set the check boxes in the next 3 cells to false.

TIA

--
Cyberwolf
Finder of Paths, Hunter of Prey
Ghost of the Night, Shadow of Day
The Wolf


"Helmut Weber" wrote:

> Hi Cyberwolf,
>
> maybe like that:
>
> Sub NextCell()
> Dim rTbl As Range
> Set rTbl = Selection.Tables(1).Range
> ' if the selection is in the last cell of a table
> If Selection.Cells(1).Range.IsEqual( _
> rTbl.Cells(rTbl.Cells.Count).Range) Then
> Selection.Rows(1).Range.Copy
> Selection.Tables(1).Rows.Add
> Selection.Tables(1).Rows.Last.Select
> Selection.Paste
> Selection.Rows(1).Delete
> Selection.MoveUp unit:=wdLine
> Else
> Selection.Cells(1).Next.Select
> Selection.Collapse
> End If
> End Sub
>
> --
>
> Greetings from Bavaria, Germany
>
> Helmut Weber, MVP WordVBA
>
> Vista Small Business, Office XP
>

Re: add checkbox to table programatically by Helmut

Helmut
Tue Apr 01 07:34:12 PDT 2008

On Tue, 1 Apr 2008 04:41:07 -0700, Cyberwolf
<Cyberwolf@discussions.microsoft.com> wrote:

>That was what I was looking for, but I do not want the value of the 1st cell
>in the copied range to be copied, or delete it once the range is copied.

I don't understand "or delete it"
>Also I want to set the check boxes in the next 3 cells to false.

Sub NextCell()
Dim rTbl As Range
Set rTbl = Selection.Tables(1).Range
If Selection.Cells(1).Range.IsEqual( _
rTbl.Cells(rTbl.Cells.Count).Range) Then
Selection.Rows(1).Range.Copy
Selection.Tables(1).Rows.Add
Selection.Tables(1).Rows.Last.Select
Selection.Paste
Selection.Rows(1).Delete
Selection.MoveUp unit:=wdLine
Selection.Rows(1).Range.FormFields(1).Result = False
' e.g. ---------------------------------------------
Selection.Rows(1).Range.FormFields(2).Result = False
Selection.Rows(1).Range.FormFields(3).Result = False
Selection.Rows(1).Range.FormFields(4).Result = False
Else
Selection.Cells(1).Next.Select
Selection.Collapse
End If
End Sub

--

Greetings from Bavaria, Germany

Helmut Weber, MVP WordVBA

Vista Small Business, Office XP