here's the code:
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
~~~~~~
The error is "Compile Error" Expected: expression and it highlights the ":="
of
Range:=ActiveDocument
How do I fix that?
Jay Freedman - 10 May 2006 04:17 GMT
All of this should be on one line:
ActiveDocument.FormFields.Add
Range:=ActiveDocument.Tables(1).Cell(rownum, i).Range,
Type:=wdFieldFormTextInput
If you have it on three lines, either delete the carriage returns to
put it all together on the same line, or insert a space and an
underscore at the ends of th first two lines -- that's the
continuation indicator
(http://www.word.mvps.org/FAQs/MacrosVBA/_AtEndOfLine.htm).
Then do the same with these three lines:
ActiveDocument.Tables(1).Cell(ActiveDocument.Tables(1).Rows.Count,
ActiveDocument.Tables(1).Columns.Count).Range.FormFields(1).ExitMacro=
"addrow"
and combine these two:
ActiveDocument.Tables(1).Cell(ActiveDocument.Tables(1).Rows.Count,
1).Range.FormFields(1).Select
--
Regards,
Jay Freedman
Microsoft Word MVP FAQ: http://word.mvps.org
Email cannot be acknowledged; please post all follow-ups to the
newsgroup so all may benefit.
>here's the code:
>
[quoted text clipped - 29 lines]
>
>How do I fix that?
Angyl - 10 May 2006 04:57 GMT
THANK YOU THANK YOU THANK YOU!!!
One more question for this project, please?
These fields that the macro is attached to perform a calculation based on
other form fields in the document such as =(Text1)*(Text2)
How could I go about attaching that calculation (along with the macro, as it
is already doing) to the new fields being created?
Jay Freedman - 11 May 2006 03:16 GMT
>THANK YOU THANK YOU THANK YOU!!!
You're welcome.
>One more question for this project, please?
>
[quoted text clipped - 3 lines]
>How could I go about attaching that calculation (along with the macro, as it
>is already doing) to the new fields being created?
It looks like Greg got you started in the right direction.
--
Regards,
Jay Freedman
Microsoft Word MVP FAQ: http://word.mvps.org
Email cannot be acknowledged; please post all follow-ups to the
newsgroup so all may benefit.