Home |
Search |
Today's Posts |
#1
Posted to microsoft.public.word.tables
|
|||
|
|||
table form exit macro add a table row
Need assistance:
I'm working with a basic table generated using 2003 ms word forms. Each cell of the table has a text form fill cell - table has one row, and five cols. The document has been saved as a template with the following macro entered into the last cell. Protection enabled. Intent is for the last cell to be used to prompt the user on exit if an additional row is needed. If yes - another row is added - if not then allowed to move on to the next section of the form which is unprotected. I found this macro -- labled to add a table row using word forms. I get the following error message: "Compile Error - Sub or Function not defined" Do I need to book mark the first cell in the table? The macro is named as Macro6 and set for exit -- bookmark is filled in as text5 Sub Macro6() ' 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 Long, i As Long Dim Response Response = MsgBox("Do you need to add another row to the table?", vbYesNo + vbQuestion + vbDefaultButton2, "Add another Row") If Response = vbYes Then ' User chose Yes. With ActiveDocument .Unprotect With Selection.Tables(1) .Rows.Add rownum = .Rows.Count For i = 1 To .Columns.Count ActiveDocument.FormFields.Add Range:=.Cell(rownum, i).Range, Type:=wdFieldFormTextInput Next i .Cell(.Rows.Count, .Columns.Count).Range.FormFields (1).ExitMacro = "addRow" .Cell(.Rows.Count, 1).Range.FormFields(1).Select End With .Protect Type:=wdAllowOnlyFormFields, NoReset:=True End With Else ' User chose No. Exit Sub End If End Sub |
#2
Posted to microsoft.public.word.tables
|
|||
|
|||
table form exit macro add a table row
The problem will be caused by line breaks inserted by the mail program. In
the following copy of the code, I have inserted linebreaks that will be recognised by the Visual Basic Editor, which should overcome the problem. ' 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 Long, i As Long Dim Response Response = MsgBox("Do you need to add another row to the table?", _ vbYesNo + vbQuestion + vbDefaultButton2, "Add another Row") If Response = vbYes Then ' User chose Yes. With ActiveDocument .Unprotect With Selection.Tables(1) .Rows.Add rownum = .Rows.Count For i = 1 To .Columns.Count ActiveDocument.FormFields.Add Range:=.Cell(rownum, _ i).Range, Type:=wdFieldFormTextInput Next i .Cell(.Rows.Count, .Columns.Count).Range.FormFields _ (1).ExitMacro = "addRow" .Cell(.Rows.Count, 1).Range.FormFields(1).Select End With .Protect Type:=wdAllowOnlyFormFields, NoReset:=True End With Else ' User chose No. Exit Sub End If -- 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, originally posted via msnews.microsoft.com "skbenlc" wrote in message ... Need assistance: I'm working with a basic table generated using 2003 ms word forms. Each cell of the table has a text form fill cell - table has one row, and five cols. The document has been saved as a template with the following macro entered into the last cell. Protection enabled. Intent is for the last cell to be used to prompt the user on exit if an additional row is needed. If yes - another row is added - if not then allowed to move on to the next section of the form which is unprotected. I found this macro -- labled to add a table row using word forms. I get the following error message: "Compile Error - Sub or Function not defined" Do I need to book mark the first cell in the table? The macro is named as Macro6 and set for exit -- bookmark is filled in as text5 Sub Macro6() ' 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 Long, i As Long Dim Response Response = MsgBox("Do you need to add another row to the table?", vbYesNo + vbQuestion + vbDefaultButton2, "Add another Row") If Response = vbYes Then ' User chose Yes. With ActiveDocument .Unprotect With Selection.Tables(1) .Rows.Add rownum = .Rows.Count For i = 1 To .Columns.Count ActiveDocument.FormFields.Add Range:=.Cell(rownum, i).Range, Type:=wdFieldFormTextInput Next i .Cell(.Rows.Count, .Columns.Count).Range.FormFields (1).ExitMacro = "addRow" .Cell(.Rows.Count, 1).Range.FormFields(1).Select End With .Protect Type:=wdAllowOnlyFormFields, NoReset:=True End With Else ' User chose No. Exit Sub End If End Sub |
#3
Posted to microsoft.public.word.tables
|
|||
|
|||
table form exit macro add a table row
On Mar 23, 3:16*am, "Doug Robbins - Word MVP on news.microsoft.com"
wrote: The problem will be caused by line breaks inserted by the mail program. *In the following copy of the code, I have inserted linebreaks that will be recognised by the Visual Basic Editor, which should overcome the problem. ' 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 Long, i As Long Dim Response Response = MsgBox("Do you need to add another row to the table?", _ vbYesNo + vbQuestion + vbDefaultButton2, "Add another Row") If Response = vbYes Then * *' User chose Yes. * * With ActiveDocument * * * * .Unprotect * * * * With Selection.Tables(1) * * * * * * .Rows.Add * * * * * * rownum = .Rows.Count * * * * * * For i = 1 To .Columns.Count * * * * * * * * ActiveDocument.FormFields.Add Range:=.Cell(rownum, _ i).Range, Type:=wdFieldFormTextInput * * * * * * Next i * * * * * * .Cell(.Rows.Count, .Columns.Count).Range.FormFields _ (1).ExitMacro = "addRow" * * * * * * .Cell(.Rows.Count, 1).Range.FormFields(1).Select * * * * End With * * * * .Protect Type:=wdAllowOnlyFormFields, NoReset:=True * * End With Else * *' User chose No. * * Exit Sub End If -- 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, originally posted via msnews.microsoft.com "skbenlc" wrote in message ... Need assistance: I'm working with a basic table generated using 2003 ms word forms. Each cell of the table has a text form fill cell - table has one row, and five cols. The document has been saved as a template with the following macro entered into the last cell. Protection enabled. Intent is for the last cell to be used to prompt the user on exit if an additional row is needed. If yes - another row is added - if not then allowed to move on to the next section of the form which is unprotected. I found this macro -- labled to add a table row using word forms. I get the following error message: *"Compile Error - Sub or Function not defined" Do I need to book mark the first cell in the table? The macro is named as Macro6 and set for exit -- bookmark is filled in as text5 Sub Macro6() ' 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 Long, i As Long Dim Response Response = MsgBox("Do you need to add another row to the table?", vbYesNo + vbQuestion + vbDefaultButton2, "Add another Row") If Response = vbYes Then * *' User chose Yes. * *With ActiveDocument * * * *.Unprotect * * * *With Selection.Tables(1) * * * * * *.Rows.Add * * * * * *rownum = .Rows.Count * * * * * *For i = 1 To .Columns.Count * * * * * * * *ActiveDocument.FormFields.Add Range:=.Cell(rownum, i).Range, Type:=wdFieldFormTextInput * * * * * *Next i * * * * * *.Cell(.Rows.Count, .Columns.Count).Range.FormFields (1).ExitMacro = "addRow" * * * * * *.Cell(.Rows.Count, 1).Range.FormFields(1).Select * * * *End With * * * *.Protect Type:=wdAllowOnlyFormFields, NoReset:=True * *End With Else * *' User chose No. * *Exit Sub End If End Sub- Hide quoted text - - Show quoted text - Entered the above macro: The only editing change I'm seeing is the _ located on the Response Line Questionf "Do you need to add another row to the table?", _ Also noted that the End Sub was omitted -- ran the macro both ways -- with, and without the End Sub.: received the same "Compile Error - Sub or Function not defined" Thanks |
#4
Posted to microsoft.public.word.tables
|
|||
|
|||
table form exit macro add a table row
The End Sub is of course required. However look a bit close and you will
see that I also altered the lines ActiveDocument.FormFields.Add Range:=.Cell(rownum, i).Range, and .Cell(.Rows.Count, .Columns.Count).Range.FormFields (1).ExitMacro = "addRow" to ActiveDocument.FormFields.Add Range:=.Cell(rownum, _ i).Range, .Cell(.Rows.Count, .Columns.Count).Range.FormFields _ (1).ExitMacro = "addRow" If you click on Debug, what line of code is highlighted. -- 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, originally posted via msnews.microsoft.com "skbenlc" wrote in message ... On Mar 23, 3:16 am, "Doug Robbins - Word MVP on news.microsoft.com" wrote: The problem will be caused by line breaks inserted by the mail program. In the following copy of the code, I have inserted linebreaks that will be recognised by the Visual Basic Editor, which should overcome the problem. ' 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 Long, i As Long Dim Response Response = MsgBox("Do you need to add another row to the table?", _ vbYesNo + vbQuestion + vbDefaultButton2, "Add another Row") If Response = vbYes Then ' User chose Yes. With ActiveDocument .Unprotect With Selection.Tables(1) .Rows.Add rownum = .Rows.Count For i = 1 To .Columns.Count ActiveDocument.FormFields.Add Range:=.Cell(rownum, _ i).Range, Type:=wdFieldFormTextInput Next i .Cell(.Rows.Count, .Columns.Count).Range.FormFields _ (1).ExitMacro = "addRow" .Cell(.Rows.Count, 1).Range.FormFields(1).Select End With .Protect Type:=wdAllowOnlyFormFields, NoReset:=True End With Else ' User chose No. Exit Sub End If -- 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, originally posted via msnews.microsoft.com "skbenlc" wrote in message ... Need assistance: I'm working with a basic table generated using 2003 ms word forms. Each cell of the table has a text form fill cell - table has one row, and five cols. The document has been saved as a template with the following macro entered into the last cell. Protection enabled. Intent is for the last cell to be used to prompt the user on exit if an additional row is needed. If yes - another row is added - if not then allowed to move on to the next section of the form which is unprotected. I found this macro -- labled to add a table row using word forms. I get the following error message: "Compile Error - Sub or Function not defined" Do I need to book mark the first cell in the table? The macro is named as Macro6 and set for exit -- bookmark is filled in as text5 Sub Macro6() ' 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 Long, i As Long Dim Response Response = MsgBox("Do you need to add another row to the table?", vbYesNo + vbQuestion + vbDefaultButton2, "Add another Row") If Response = vbYes Then ' User chose Yes. With ActiveDocument .Unprotect With Selection.Tables(1) .Rows.Add rownum = .Rows.Count For i = 1 To .Columns.Count ActiveDocument.FormFields.Add Range:=.Cell(rownum, i).Range, Type:=wdFieldFormTextInput Next i .Cell(.Rows.Count, .Columns.Count).Range.FormFields (1).ExitMacro = "addRow" .Cell(.Rows.Count, 1).Range.FormFields(1).Select End With .Protect Type:=wdAllowOnlyFormFields, NoReset:=True End With Else ' User chose No. Exit Sub End If End Sub- Hide quoted text - - Show quoted text - Entered the above macro: The only editing change I'm seeing is the _ located on the Response Line Questionf "Do you need to add another row to the table?", _ Also noted that the End Sub was omitted -- ran the macro both ways -- with, and without the End Sub.: received the same "Compile Error - Sub or Function not defined" Thanks |
#5
Posted to microsoft.public.word.tables
|
|||
|
|||
table form exit macro add a table row
On Mar 23, 6:04*pm, "Doug Robbins - Word MVP on news.microsoft.com"
wrote: The End Sub is of course required. *However look a bit close and you will see that I also altered the lines * * * * * * * *ActiveDocument.FormFields.Add Range:=.Cell(rownum, i).Range, and * * * * * * .Cell(.Rows.Count, .Columns.Count).Range.FormFields (1).ExitMacro = "addRow" to * * * * * * * * ActiveDocument.FormFields.Add Range:=.Cell(rownum, _ i).Range, * * * * * * .Cell(.Rows.Count, .Columns.Count).Range.FormFields _ (1).ExitMacro = "addRow" If you click on Debug, what line of code is highlighted. -- 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, originally posted via msnews.microsoft.com "skbenlc" wrote in message ... On Mar 23, 3:16 am, "Doug Robbins - Word MVP on news.microsoft.com" wrote: The problem will be caused by line breaks inserted by the mail program. In the following copy of the code, I have inserted linebreaks that will be recognised by the Visual Basic Editor, which should overcome the problem. ' 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 Long, i As Long Dim Response Response = MsgBox("Do you need to add another row to the table?", _ vbYesNo + vbQuestion + vbDefaultButton2, "Add another Row") If Response = vbYes Then ' User chose Yes. With ActiveDocument .Unprotect With Selection.Tables(1) .Rows.Add rownum = .Rows.Count For i = 1 To .Columns.Count ActiveDocument.FormFields.Add Range:=.Cell(rownum, _ i).Range, Type:=wdFieldFormTextInput Next i .Cell(.Rows.Count, .Columns.Count).Range.FormFields _ (1).ExitMacro = "addRow" .Cell(.Rows.Count, 1).Range.FormFields(1).Select End With .Protect Type:=wdAllowOnlyFormFields, NoReset:=True End With Else ' User chose No. Exit Sub End If -- 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, originally posted via msnews.microsoft.com "skbenlc" wrote in message .... Need assistance: I'm working with a basic table generated using 2003 ms word forms. Each cell of the table has a text form fill cell - table has one row, and five cols. The document has been saved as a template with the following macro entered into the last cell. Protection enabled. Intent is for the last cell to be used to prompt the user on exit if an additional row is needed. If yes - another row is added - if not then allowed to move on to the next section of the form which is unprotected. I found this macro -- labled to add a table row using word forms. I get the following error message: "Compile Error - Sub or Function not defined" Do I need to book mark the first cell in the table? The macro is named as Macro6 and set for exit -- bookmark is filled in as text5 Sub Macro6() ' 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 Long, i As Long Dim Response Response = MsgBox("Do you need to add another row to the table?", vbYesNo + vbQuestion + vbDefaultButton2, "Add another Row") If Response = vbYes Then ' User chose Yes. With ActiveDocument .Unprotect With Selection.Tables(1) .Rows.Add rownum = .Rows.Count For i = 1 To .Columns.Count ActiveDocument.FormFields.Add Range:=.Cell(rownum, i).Range, Type:=wdFieldFormTextInput Next i .Cell(.Rows.Count, .Columns.Count).Range.FormFields (1).ExitMacro = "addRow" .Cell(.Rows.Count, 1).Range.FormFields(1).Select End With .Protect Type:=wdAllowOnlyFormFields, NoReset:=True End With Else ' User chose No. Exit Sub End If End Sub- Hide quoted text - - Show quoted text - Entered the above macro: *The only editing change I'm seeing is the _ located on the Response Line Questionf "Do you need to add another row to the table?", _ Also noted that the End Sub was omitted -- ran the macro both ways -- with, and without the End Sub.: *received the same "Compile Error - Sub or Function not defined" Thanks- Hide quoted text - - Show quoted text - In clicking on debug -- Quickwatch: obtained the following: Normal.newmacros.macro6 Expression the Value can't compile module I rechecked the text form field options: have the following settings: Reg. text, Max. Length - Unlimited Exit Macro6 bookmark Text 7 Fill in enabled box is checked Calculate on exit is unchecked: also tried to run with Calculate on exit checked -- same error. Using Debug -- Step Intro cursor stops on "the" Thanks for your review, and comments. |
#6
Posted to microsoft.public.word.tables
|
|||
|
|||
table form exit macro add a table row
the
the Table are intended to be part of the comment on the previous row. Move them to the end of the line of code ' automatically on exit from the last cell in the present last row of so that it reads ' automatically on exit from the last cell in the present last row of the Table -- 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, originally posted via msnews.microsoft.com "skbenlc" wrote in message ... On Mar 23, 6:04 pm, "Doug Robbins - Word MVP on news.microsoft.com" wrote: The End Sub is of course required. However look a bit close and you will see that I also altered the lines ActiveDocument.FormFields.Add Range:=.Cell(rownum, i).Range, and .Cell(.Rows.Count, .Columns.Count).Range.FormFields (1).ExitMacro = "addRow" to ActiveDocument.FormFields.Add Range:=.Cell(rownum, _ i).Range, .Cell(.Rows.Count, .Columns.Count).Range.FormFields _ (1).ExitMacro = "addRow" If you click on Debug, what line of code is highlighted. -- 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, originally posted via msnews.microsoft.com "skbenlc" wrote in message ... On Mar 23, 3:16 am, "Doug Robbins - Word MVP on news.microsoft.com" wrote: The problem will be caused by line breaks inserted by the mail program. In the following copy of the code, I have inserted linebreaks that will be recognised by the Visual Basic Editor, which should overcome the problem. ' 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 Long, i As Long Dim Response Response = MsgBox("Do you need to add another row to the table?", _ vbYesNo + vbQuestion + vbDefaultButton2, "Add another Row") If Response = vbYes Then ' User chose Yes. With ActiveDocument .Unprotect With Selection.Tables(1) .Rows.Add rownum = .Rows.Count For i = 1 To .Columns.Count ActiveDocument.FormFields.Add Range:=.Cell(rownum, _ i).Range, Type:=wdFieldFormTextInput Next i .Cell(.Rows.Count, .Columns.Count).Range.FormFields _ (1).ExitMacro = "addRow" .Cell(.Rows.Count, 1).Range.FormFields(1).Select End With .Protect Type:=wdAllowOnlyFormFields, NoReset:=True End With Else ' User chose No. Exit Sub End If -- 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, originally posted via msnews.microsoft.com "skbenlc" wrote in message ... Need assistance: I'm working with a basic table generated using 2003 ms word forms. Each cell of the table has a text form fill cell - table has one row, and five cols. The document has been saved as a template with the following macro entered into the last cell. Protection enabled. Intent is for the last cell to be used to prompt the user on exit if an additional row is needed. If yes - another row is added - if not then allowed to move on to the next section of the form which is unprotected. I found this macro -- labled to add a table row using word forms. I get the following error message: "Compile Error - Sub or Function not defined" Do I need to book mark the first cell in the table? The macro is named as Macro6 and set for exit -- bookmark is filled in as text5 Sub Macro6() ' 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 Long, i As Long Dim Response Response = MsgBox("Do you need to add another row to the table?", vbYesNo + vbQuestion + vbDefaultButton2, "Add another Row") If Response = vbYes Then ' User chose Yes. With ActiveDocument .Unprotect With Selection.Tables(1) .Rows.Add rownum = .Rows.Count For i = 1 To .Columns.Count ActiveDocument.FormFields.Add Range:=.Cell(rownum, i).Range, Type:=wdFieldFormTextInput Next i .Cell(.Rows.Count, .Columns.Count).Range.FormFields (1).ExitMacro = "addRow" .Cell(.Rows.Count, 1).Range.FormFields(1).Select End With .Protect Type:=wdAllowOnlyFormFields, NoReset:=True End With Else ' User chose No. Exit Sub End If End Sub- Hide quoted text - - Show quoted text - Entered the above macro: The only editing change I'm seeing is the _ located on the Response Line Questionf "Do you need to add another row to the table?", _ Also noted that the End Sub was omitted -- ran the macro both ways -- with, and without the End Sub.: received the same "Compile Error - Sub or Function not defined" Thanks- Hide quoted text - - Show quoted text - In clicking on debug -- Quickwatch: obtained the following: Normal.newmacros.macro6 Expression the Value can't compile module I rechecked the text form field options: have the following settings: Reg. text, Max. Length - Unlimited Exit Macro6 bookmark Text 7 Fill in enabled box is checked Calculate on exit is unchecked: also tried to run with Calculate on exit checked -- same error. Using Debug -- Step Intro cursor stops on "the" Thanks for your review, and comments. |
#7
Posted to microsoft.public.word.tables
|
|||
|
|||
table form exit macro add a table row
On Mar 23, 10:48*pm, "Doug Robbins - Word MVP on news.microsoft.com"
wrote: the the Table are intended to be part of the comment on the previous row. *Move them to the end of the line of code *' automatically on exit from the last cell in the present last row of so that it reads *' automatically on exit from the last cell in the present last row of the Table -- 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, originally posted via msnews.microsoft.com "skbenlc" wrote in message ... On Mar 23, 6:04 pm, "Doug Robbins - Word MVP on news.microsoft.com" wrote: The End Sub is of course required. However look a bit close and you will see that I also altered the lines ActiveDocument.FormFields.Add Range:=.Cell(rownum, i).Range, and .Cell(.Rows.Count, .Columns.Count).Range.FormFields (1).ExitMacro = "addRow" to ActiveDocument.FormFields.Add Range:=.Cell(rownum, _ i).Range, .Cell(.Rows.Count, .Columns.Count).Range.FormFields _ (1).ExitMacro = "addRow" If you click on Debug, what line of code is highlighted. -- 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, originally posted via msnews.microsoft.com "skbenlc" wrote in message .... On Mar 23, 3:16 am, "Doug Robbins - Word MVP on news.microsoft.com" wrote: The problem will be caused by line breaks inserted by the mail program. In the following copy of the code, I have inserted linebreaks that will be recognised by the Visual Basic Editor, which should overcome the problem. ' 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 Long, i As Long Dim Response Response = MsgBox("Do you need to add another row to the table?", _ vbYesNo + vbQuestion + vbDefaultButton2, "Add another Row") If Response = vbYes Then ' User chose Yes. With ActiveDocument .Unprotect With Selection.Tables(1) .Rows.Add rownum = .Rows.Count For i = 1 To .Columns.Count ActiveDocument.FormFields.Add Range:=.Cell(rownum, _ i).Range, Type:=wdFieldFormTextInput Next i .Cell(.Rows.Count, .Columns.Count).Range.FormFields _ (1).ExitMacro = "addRow" .Cell(.Rows.Count, 1).Range.FormFields(1).Select End With .Protect Type:=wdAllowOnlyFormFields, NoReset:=True End With Else ' User chose No. Exit Sub End If -- 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, originally posted via msnews.microsoft.com "skbenlc" wrote in message .... Need assistance: I'm working with a basic table generated using 2003 ms word forms. Each cell of the table has a text form fill cell - table has one row, and five cols. The document has been saved as a template with the following macro entered into the last cell. Protection enabled. Intent is for the last cell to be used to prompt the user on exit if an additional row is needed. If yes - another row is added - if not then allowed to move on to the next section of the form which is unprotected. I found this macro -- labled to add a table row using word forms. I get the following error message: "Compile Error - Sub or Function not defined" Do I need to book mark the first cell in the table? The macro is named as Macro6 and set for exit -- bookmark is filled in as text5 Sub Macro6() ' 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 Long, i As Long Dim Response Response = MsgBox("Do you need to add another row to the table?", vbYesNo + vbQuestion + vbDefaultButton2, "Add another Row") If Response = vbYes Then ' User chose Yes. With ActiveDocument .Unprotect With Selection.Tables(1) .Rows.Add rownum = .Rows.Count For i = 1 To .Columns.Count ActiveDocument.FormFields.Add Range:=.Cell(rownum, i).Range, Type:=wdFieldFormTextInput Next i .Cell(.Rows.Count, .Columns.Count).Range.FormFields (1).ExitMacro = "addRow" .Cell(.Rows.Count, 1).Range.FormFields(1).Select End With .Protect Type:=wdAllowOnlyFormFields, NoReset:=True End With Else ' User chose No. Exit Sub End If End Sub- Hide quoted text - - Show quoted text - Entered the above macro: The only editing change I'm seeing is the _ located on the Response Line Questionf "Do you need to add another row to the table?", _ Also noted that the End Sub was omitted -- ran the macro both ways -- with, and without the End Sub.: received the same "Compile Error - Sub or Function not defined" Thanks- Hide quoted text - - Show quoted text - In clicking on debug -- Quickwatch: *obtained the following: Normal.newmacros.macro6 Expression * * * * * * * the Value * * * * * * can't compile module I rechecked the text form field options: *have the following settings: *Reg. text, *Max. Length - Unlimited Exit Macro6 * * *bookmark * * * * Text 7 * * * *Fill in enabled box is checked * * * * Calculate on exit is unchecked: also tried to run with Calculate on exit checked -- same error. Using Debug -- Step Intro cursor stops on "the" Thanks for your review, and comments.- Hide quoted text - - Show quoted text - Edits completed for the comment line moving "the Table" Macro now runs about to mid way generating a Syntax error The line starting with Active is highlighted: the following line begining with Type is in red text. ActiveDocument.FormFields.Add Range:=.Cell(rownum, _ i).Range, Type:=wdFieldFormTextInput Thanks for the commens. |
#8
Posted to microsoft.public.word.tables
|
|||
|
|||
table form exit macro add a table row
On Mar 24, 8:50*am, skbenlc wrote:
On Mar 23, 10:48*pm, "Doug Robbins - Word MVP on news.microsoft.com" wrote: the the Table are intended to be part of the comment on the previous row. *Move them to the end of the line of code *' automatically on exit from the last cell in the present last row of so that it reads *' automatically on exit from the last cell in the present last row of the Table -- 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, originally posted via msnews.microsoft.com "skbenlc" wrote in message .... On Mar 23, 6:04 pm, "Doug Robbins - Word MVP on news.microsoft.com" wrote: The End Sub is of course required. However look a bit close and you will see that I also altered the lines ActiveDocument.FormFields.Add Range:=.Cell(rownum, i).Range, and .Cell(.Rows.Count, .Columns.Count).Range.FormFields (1).ExitMacro = "addRow" to ActiveDocument.FormFields.Add Range:=.Cell(rownum, _ i).Range, .Cell(.Rows.Count, .Columns.Count).Range.FormFields _ (1).ExitMacro = "addRow" If you click on Debug, what line of code is highlighted. -- 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, originally posted via msnews.microsoft.com "skbenlc" wrote in message .... On Mar 23, 3:16 am, "Doug Robbins - Word MVP on news.microsoft.com" wrote: The problem will be caused by line breaks inserted by the mail program. In the following copy of the code, I have inserted linebreaks that will be recognised by the Visual Basic Editor, which should overcome the problem. ' 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 Long, i As Long Dim Response Response = MsgBox("Do you need to add another row to the table?", _ vbYesNo + vbQuestion + vbDefaultButton2, "Add another Row") If Response = vbYes Then ' User chose Yes. With ActiveDocument .Unprotect With Selection.Tables(1) .Rows.Add rownum = .Rows.Count For i = 1 To .Columns.Count ActiveDocument.FormFields.Add Range:=.Cell(rownum, _ i).Range, Type:=wdFieldFormTextInput Next i .Cell(.Rows.Count, .Columns.Count).Range.FormFields _ (1).ExitMacro = "addRow" .Cell(.Rows.Count, 1).Range.FormFields(1).Select End With .Protect Type:=wdAllowOnlyFormFields, NoReset:=True End With Else ' User chose No. Exit Sub End If -- 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, originally posted via msnews.microsoft.com "skbenlc" wrote in message ... Need assistance: I'm working with a basic table generated using 2003 ms word forms.. Each cell of the table has a text form fill cell - table has one row, and five cols. The document has been saved as a template with the following macro entered into the last cell. Protection enabled. Intent is for the last cell to be used to prompt the user on exit if an additional row is needed. If yes - another row is added - if not then allowed to move on to the next section of the form which is unprotected. I found this macro -- labled to add a table row using word forms. I get the following error message: "Compile Error - Sub or Function not defined" Do I need to book mark the first cell in the table? The macro is named as Macro6 and set for exit -- bookmark is filled in as text5 Sub Macro6() ' 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 Long, i As Long Dim Response Response = MsgBox("Do you need to add another row to the table?", vbYesNo + vbQuestion + vbDefaultButton2, "Add another Row") If Response = vbYes Then ' User chose Yes. With ActiveDocument .Unprotect With Selection.Tables(1) .Rows.Add rownum = .Rows.Count For i = 1 To .Columns.Count ActiveDocument.FormFields.Add Range:=.Cell(rownum, i).Range, Type:=wdFieldFormTextInput Next i .Cell(.Rows.Count, .Columns.Count).Range.FormFields (1).ExitMacro = "addRow" .Cell(.Rows.Count, 1).Range.FormFields(1).Select End With .Protect Type:=wdAllowOnlyFormFields, NoReset:=True End With Else ' User chose No. Exit Sub End If End Sub- Hide quoted text - - Show quoted text - Entered the above macro: The only editing change I'm seeing is the _ located on the Response Line Questionf "Do you need to add another row to the table?", _ Also noted that the End Sub was omitted -- ran the macro both ways -- with, and without the End Sub.: received the same "Compile Error - Sub or Function not defined" Thanks- Hide quoted text - - Show quoted text - In clicking on debug -- Quickwatch: *obtained the following: Normal.newmacros.macro6 Expression * * * * * * * the Value * * * * * * can't compile module I rechecked the text form field options: *have the following settings: *Reg. text, *Max. Length - Unlimited Exit Macro6 * * *bookmark * * * * Text 7 * * * *Fill in enabled box is checked * * * * Calculate on exit is unchecked: also tried to run with Calculate on exit checked -- same error. Using Debug -- Step Intro cursor stops on "the" Thanks for your review, and comments.- Hide quoted text - - Show quoted text - Edits completed for the comment line moving "the Table" Macro now runs about to mid way generating a Syntax error The line starting with Active is highlighted: *the following line begining with Type is in red text. * * * * * * * * ActiveDocument.FormFields.Add Range:=.Cell(rownum, _ i).Range, Type:=wdFieldFormTextInput Thanks for the commens.- Hide quoted text - - Show quoted text - Edit made to the ActiveDocument.Form line: Macro is now Launches on exit from last field in the table. I get the prompt message "Do you need to add another row to the table" When I select yes - get the following error: run time error "5485" The password is incorrect In checking debug: cursor stops on: .Unprotect Do I need to edit the line with .Unprotect(name of password) Thanks |
#9
Posted to microsoft.public.word.tables
|
|||
|
|||
table form exit macro add a table row
On Mar 24, 3:25*pm, skbenlc wrote:
On Mar 24, 8:50*am, skbenlc wrote: On Mar 23, 10:48*pm, "Doug Robbins - Word MVP on news.microsoft.com" wrote: the the Table are intended to be part of the comment on the previous row. *Move them to the end of the line of code *' automatically on exit from the last cell in the present last row of so that it reads *' automatically on exit from the last cell in the present last row of the Table -- 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, originally posted via msnews.microsoft.com "skbenlc" wrote in message .... On Mar 23, 6:04 pm, "Doug Robbins - Word MVP on news.microsoft.com" wrote: The End Sub is of course required. However look a bit close and you will see that I also altered the lines ActiveDocument.FormFields.Add Range:=.Cell(rownum, i).Range, and .Cell(.Rows.Count, .Columns.Count).Range.FormFields (1).ExitMacro = "addRow" to ActiveDocument.FormFields.Add Range:=.Cell(rownum, _ i).Range, .Cell(.Rows.Count, .Columns.Count).Range.FormFields _ (1).ExitMacro = "addRow" If you click on Debug, what line of code is highlighted. -- 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, originally posted via msnews.microsoft.com "skbenlc" wrote in message ... On Mar 23, 3:16 am, "Doug Robbins - Word MVP on news.microsoft.com" wrote: The problem will be caused by line breaks inserted by the mail program. In the following copy of the code, I have inserted linebreaks that will be recognised by the Visual Basic Editor, which should overcome the problem. ' 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 Long, i As Long Dim Response Response = MsgBox("Do you need to add another row to the table?", _ vbYesNo + vbQuestion + vbDefaultButton2, "Add another Row") If Response = vbYes Then ' User chose Yes. With ActiveDocument .Unprotect With Selection.Tables(1) .Rows.Add rownum = .Rows.Count For i = 1 To .Columns.Count ActiveDocument.FormFields.Add Range:=.Cell(rownum, _ i).Range, Type:=wdFieldFormTextInput Next i .Cell(.Rows.Count, .Columns.Count).Range.FormFields _ (1).ExitMacro = "addRow" .Cell(.Rows.Count, 1).Range.FormFields(1).Select End With .Protect Type:=wdAllowOnlyFormFields, NoReset:=True End With Else ' User chose No. Exit Sub End If -- 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, originally posted via msnews.microsoft.com "skbenlc" wrote in message ... Need assistance: I'm working with a basic table generated using 2003 ms word forms. Each cell of the table has a text form fill cell - table has one row, and five cols. The document has been saved as a template with the following macro entered into the last cell. Protection enabled. Intent is for the last cell to be used to prompt the user on exit if an additional row is needed. If yes - another row is added - if not then allowed to move on to the next section of the form which is unprotected. I found this macro -- labled to add a table row using word forms. I get the following error message: "Compile Error - Sub or Function not defined" Do I need to book mark the first cell in the table? The macro is named as Macro6 and set for exit -- bookmark is filled in as text5 Sub Macro6() ' 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 Long, i As Long Dim Response Response = MsgBox("Do you need to add another row to the table?", vbYesNo + vbQuestion + vbDefaultButton2, "Add another Row") If Response = vbYes Then ' User chose Yes. With ActiveDocument .Unprotect With Selection.Tables(1) .Rows.Add rownum = .Rows.Count For i = 1 To .Columns.Count ActiveDocument.FormFields.Add Range:=.Cell(rownum, i).Range, Type:=wdFieldFormTextInput Next i .Cell(.Rows.Count, .Columns.Count).Range.FormFields (1).ExitMacro = "addRow" .Cell(.Rows.Count, 1).Range.FormFields(1).Select End With .Protect Type:=wdAllowOnlyFormFields, NoReset:=True End With Else ' User chose No. Exit Sub End If End Sub- Hide quoted text - - Show quoted text - Entered the above macro: The only editing change I'm seeing is the _ located on the Response Line Questionf "Do you need to add another row to the table?", _ Also noted that the End Sub was omitted -- ran the macro both ways -- with, and without the End Sub.: received the same "Compile Error - Sub or Function not defined" Thanks- Hide quoted text - - Show quoted text - In clicking on debug -- Quickwatch: *obtained the following: Normal.newmacros.macro6 Expression * * * * * * * the Value * * * * * * can't compile module I rechecked the text form field options: *have the following settings: *Reg. text, *Max. Length - Unlimited Exit Macro6 * * *bookmark * * * * Text 7 * * * *Fill in enabled box is checked * * * * Calculate on exit is unchecked: also tried to run with Calculate on exit checked -- same error. Using Debug -- Step Intro cursor stops on "the" Thanks for your review, and comments.- Hide quoted text - - Show quoted text - Edits completed for the comment line moving "the Table" Macro now runs about to mid way generating a Syntax error The line starting with Active is highlighted: *the following line begining with Type is in red text. * * * * * * * * ActiveDocument.FormFields.Add Range:=..Cell(rownum, _ i).Range, Type:=wdFieldFormTextInput Thanks for the commens.- Hide quoted text - - Show quoted text - Edit made to the ActiveDocument.Form line: Macro is now Launches on exit from last field in the table. I get the prompt message "Do you need to add another row to the table" When I select yes *- get the following error: run time error "5485" The password is incorrect In checking debug: cursor stops on: *.Unprotect Do I need to edit the line with * .Unprotect(name of password) Thanks- Hide quoted text - - Show quoted text - ________________________________________ ..Unprotect line edit made with the following: ..Unprotect Password:="smith" Program now executes beyond Password line: executes to line the following line - ..Cell(.Rows.Count, .Columns.Count).Range.FormFields _ (1).ExitMacro = "addRow" returns run time error "4120" Bad parameter getting closer -- thanks for any commets |
#10
Posted to microsoft.public.word.tables
|
|||
|
|||
table form exit macro add a table row
On Mar 24, 3:56*pm, skbenlc wrote:
On Mar 24, 3:25*pm, skbenlc wrote: On Mar 24, 8:50*am, skbenlc wrote: On Mar 23, 10:48*pm, "Doug Robbins - Word MVP on news.microsoft.com" wrote: the the Table are intended to be part of the comment on the previous row. *Move them to the end of the line of code *' automatically on exit from the last cell in the present last row of so that it reads *' automatically on exit from the last cell in the present last row of the Table -- 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, originally posted via msnews.microsoft.com "skbenlc" wrote in message ... On Mar 23, 6:04 pm, "Doug Robbins - Word MVP on news.microsoft.com" wrote: The End Sub is of course required. However look a bit close and you will see that I also altered the lines ActiveDocument.FormFields.Add Range:=.Cell(rownum, i).Range, and .Cell(.Rows.Count, .Columns.Count).Range.FormFields (1).ExitMacro = "addRow" to ActiveDocument.FormFields.Add Range:=.Cell(rownum, _ i).Range, .Cell(.Rows.Count, .Columns.Count).Range.FormFields _ (1).ExitMacro = "addRow" If you click on Debug, what line of code is highlighted. -- 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, originally posted via msnews.microsoft.com "skbenlc" wrote in message ... On Mar 23, 3:16 am, "Doug Robbins - Word MVP on news.microsoft.com" wrote: The problem will be caused by line breaks inserted by the mail program. In the following copy of the code, I have inserted linebreaks that will be recognised by the Visual Basic Editor, which should overcome the problem. ' 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 Long, i As Long Dim Response Response = MsgBox("Do you need to add another row to the table?", _ vbYesNo + vbQuestion + vbDefaultButton2, "Add another Row") If Response = vbYes Then ' User chose Yes. With ActiveDocument .Unprotect With Selection.Tables(1) .Rows.Add rownum = .Rows.Count For i = 1 To .Columns.Count ActiveDocument.FormFields.Add Range:=.Cell(rownum, _ i).Range, Type:=wdFieldFormTextInput Next i .Cell(.Rows.Count, .Columns.Count).Range.FormFields _ (1).ExitMacro = "addRow" .Cell(.Rows.Count, 1).Range.FormFields(1).Select End With .Protect Type:=wdAllowOnlyFormFields, NoReset:=True End With Else ' User chose No. Exit Sub End If -- 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, originally posted via msnews.microsoft..com "skbenlc" wrote in message ... Need assistance: I'm working with a basic table generated using 2003 ms word forms. Each cell of the table has a text form fill cell - table has one row, and five cols. The document has been saved as a template with the following macro entered into the last cell. Protection enabled. Intent is for the last cell to be used to prompt the user on exit if an additional row is needed. If yes - another row is added - if not then allowed to move on to the next section of the form which is unprotected. I found this macro -- labled to add a table row using word forms. I get the following error message: "Compile Error - Sub or Function not defined" Do I need to book mark the first cell in the table? The macro is named as Macro6 and set for exit -- bookmark is filled in as text5 Sub Macro6() ' 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 Long, i As Long Dim Response Response = MsgBox("Do you need to add another row to the table?", vbYesNo + vbQuestion + vbDefaultButton2, "Add another Row") If Response = vbYes Then ' User chose Yes. With ActiveDocument .Unprotect With Selection.Tables(1) .Rows.Add rownum = .Rows.Count For i = 1 To .Columns.Count ActiveDocument.FormFields.Add Range:=.Cell(rownum, i).Range, Type:=wdFieldFormTextInput Next i .Cell(.Rows.Count, .Columns.Count).Range.FormFields (1).ExitMacro = "addRow" .Cell(.Rows.Count, 1).Range.FormFields(1).Select End With .Protect Type:=wdAllowOnlyFormFields, NoReset:=True End With Else ' User chose No. Exit Sub End If End Sub- Hide quoted text - - Show quoted text - Entered the above macro: The only editing change I'm seeing is the _ located on the Response Line Questionf "Do you need to add another row to the table?", _ Also noted that the End Sub was omitted -- ran the macro both ways -- with, and without the End Sub.: received the same "Compile Error - Sub or Function not defined" Thanks- Hide quoted text - - Show quoted text - In clicking on debug -- Quickwatch: *obtained the following: Normal.newmacros.macro6 Expression * * * * * * * the Value * * * * * * can't compile module I rechecked the text form field options: *have the following settings: *Reg. text, *Max. Length - Unlimited Exit Macro6 * * *bookmark * * * * Text 7 * * * *Fill in enabled box is checked * * * * Calculate on exit is unchecked: also tried to run with Calculate on exit checked -- same error. Using Debug -- Step Intro cursor stops on "the" Thanks for your review, and comments.- Hide quoted text - - Show quoted text - Edits completed for the comment line moving "the Table" Macro now runs about to mid way generating a Syntax error The line starting with Active is highlighted: *the following line begining with Type is in red text. * * * * * * * * ActiveDocument.FormFields.Add Range:=.Cell(rownum, _ i).Range, Type:=wdFieldFormTextInput Thanks for the commens.- Hide quoted text - - Show quoted text - Edit made to the ActiveDocument.Form line: Macro is now Launches on exit from last field in the table. I get the prompt message "Do you need to add another row to the table" When I select yes *- get the following error: run time error "5485" The password is incorrect In checking debug: cursor stops on: *.Unprotect Do I need to edit the line with * .Unprotect(name of password) Thanks- Hide quoted text - - Show quoted text - ________________________________________ .Unprotect line edit made with the following: .Unprotect Password:="smith" Program now executes beyond Password line: executes to line the following line - .Cell(.Rows.Count, .Columns.Count).Range.FormFields _ (1).ExitMacro = "addRow" returns run time error "4120" Bad parameter getting closer -- thanks for any commets- Hide quoted text - - Show quoted text - __________________________________________________ __- I know this is getting to be a long string: The macro is now generating the following results: exit last table cell - macro executes -- produces run time error "4120" Bad parameter When I select "End" I have the following results: Row is generated for the table Document is in a unprotected state When I reinstate protection the two cells with drom down info do not appear. The cells in the original row are still active with their drop down selections. revised macro now reads as follows: Sub Macro6() ' 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 Long, i As Long Dim Response Response = MsgBox("Do you need to add another row to the table?", _ vbYesNo + vbQuestion + vbDefaultButton2, "Add another Row") If Response = vbYes Then ' User chose Yes. With ActiveDocument .Unprotect Password:="smith" With Selection.Tables(1) .Rows.Add rownum = .Rows.Count For i = 1 To .Columns.Count ActiveDocument.FormFields.Add Range:=.Cell(rownum, _ i).Range, Type:=wdFieldFormTextInput Next i .Cell(.Rows.Count, .Columns.Count).Range.FormFields _ (1).ExitMacro = "addRow" .Cell(.Rows.Count, 1).Range.FormFields(1).Select End With .Protect Type:=wdAllowOnlyFormFields, NoReset:=True End With Else ' User chose No. Exit Sub End If End Sub Thanks for your comments. |
#11
Posted to microsoft.public.word.tables
|
|||
|
|||
table form exit macro add a table row
|
Reply |
Thread Tools | |
Display Modes | |
|
|
Similar Threads | ||||
Thread | Forum | |||
Exit a table in Word | Microsoft Word Help | |||
How can I create an exit macro to validate a Text Form Field? | Microsoft Word Help | |||
Form Fields Macro on exit problem | Microsoft Word Help | |||
Up arrow key will not exit table cell. Why? | New Users | |||
Need macro to locate table uniquely, insert blank row and date and end table | Tables |