Re: Add new row in Table + new set of Form Fields

Tech-Archive recommends: Fix windows errors by optimizing your registry



One more thing...I also get a "Can't execute code in break mode" message when
I try to run the macro when the form is protected.

"shanbones" wrote:

> Doug,
>
> Thank you. That took care of the line spacing issues. However, I still
> receive an error message ("Compile Error: Expected: expression") highlighting
> the := after "Range." Please advise.
>
> Thank you,
> shanbones
>
> "Doug Robbins" wrote:
>
> > The mail program has inserted a line break. In the VBE, place the cursor
> > before Type and press the backspace key until the two lines of code become
> > one, or insert a VBA line break by inserting a space then and underscore
> > character after the , at the end of the first line
> >
> > Range:=ActiveDocument.Tables(1).Cell(rownum, i).Range, _
> > Type:=wdFieldFormTextInput
> >
> > --
> > Hope this helps.
> >
> > Please reply to the newsgroup unless you wish to avail yourself of my
> > services on a paid consulting basis.
> >
> > Doug Robbins - Word MVP
> > "shanbones" <shanbones@xxxxxxxxxxxxxxxxxxxxxxxxx> wrote in message
> > news:DB04B54E-2A3A-4435-9616-46F53C4298D0@xxxxxxxxxxxxxxxx
> > >I have attempted to use this macro but I am getting an error message when I
> > > copy/paste it. The following areas turn red:
> > >
> > > Range:=ActiveDocument.Tables(1).Cell(rownum, i).Range,
> > > Type:=wdFieldFormTextInput
> > >
> > > Next i
> > >
> > > ActiveDocument.Tables(1).Cell(ActiveDocument.Tables(1).Rows.Count,
> > > ActiveDocument.Tables(1).Columns.Count).Range.FormFields(1).ExitMacro =
> > > "addrow"
> > >
> > > ActiveDocument.Tables(1).Cell(ActiveDocument.Tables(1).Rows.Count,
> > > 1).Range.FormFields(1).Select
> > >
> > >
> > > I thought, at first that maybe I had a line wrapping problem, but I am
> > > also
> > > getting a "Compile Error: Expected: expression" for the following area:
> > >
> > > Range:=
> > >
> > > TYIA for your assistance,
> > > shanbones
> > >
> > >
> > > "Doug Robbins" wrote:
> > >
> > >> If there is more than one table in the document, change
> > >> ActiveDocument.Tables(1) to Selection.Tables(1) in the following code
> > >>
> > >> ' Macro created 02/02/03 by Doug Robbins
> > >>
> > >> ' To add a new row to a table containing formfields in every column
> > >>
> > >> ' automatically on exit from the last cell in the present last row of the
> > >> table
> > >>
> > >> Dim rownum As Integer, i As Integer
> > >>
> > >> ActiveDocument.Unprotect
> > >>
> > >> ActiveDocument.Tables(1).Rows.Add
> > >>
> > >> rownum = ActiveDocument.Tables(1).Rows.Count
> > >>
> > >> For i = 1 To ActiveDocument.Tables(1).Columns.Count
> > >>
> > >> ActiveDocument.FormFields.Add
> > >> Range:=ActiveDocument.Tables(1).Cell(rownum, i).Range,
> > >> Type:=wdFieldFormTextInput
> > >>
> > >> Next i
> > >>
> > >> ActiveDocument.Tables(1).Cell(ActiveDocument.Tables(1).Rows.Count,
> > >> ActiveDocument.Tables(1).Columns.Count).Range.FormFields(1).ExitMacro =
> > >> "addrow"
> > >>
> > >> ActiveDocument.Tables(1).Cell(ActiveDocument.Tables(1).Rows.Count,
> > >> 1).Range.FormFields(1).Select
> > >>
> > >> ActiveDocument.Protect Type:=wdAllowOnlyFormFields, NoReset:=True
> > >>
> > >>
> > >> --
> > >> Hope this helps.
> > >>
> > >> Please reply to the newsgroup unless you wish to avail yourself of my
> > >> services on a paid consulting basis.
> > >>
> > >> Doug Robbins - Word MVP
> > >> "richardall" <allisonrdmm@xxxxxxxxx> wrote in message
> > >> news:c5aaa2e724df87011d95c525ebff79c0@xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx
> > >> >I followed the recommendations listed above but didn't have the same
> > >> > success. I think my problem is that I have 3 tables in my document and
> > >> > they are different column count.
> > >> >
> > >> > Could this script be written to look to see what the current row is and
> > >> > duplicate it no matter how many columns it has and copy in the same
> > >> > field
> > >> > types?
> > >> >
> > >> > This would make it extremely flexible and usable in many uses.
> > >> >
> > >> > Greatest regards,
> > >> > Richard
> > >> >
> > >> >
> > >>
> > >>
> > >>
> >
> >
> >
.



Relevant Pages

  • Re: Add new row in Table + new set of Form Fields
    ... or insert a VBA line break by inserting a space then and underscore ... > Doug Robbins - Word MVP ... >>> services on a paid consulting basis. ...
    (microsoft.public.word.vba.general)
  • RE: Adding a row (macro) ***One additional note***
    ... When I try to run the macro with the form in ... an unprotected/unlocked state it works just fine. ... "shanbones" wrote: ... > hightlighting does not highlight that section but has moved to the line above ...
    (microsoft.public.word.vba.general)