I would like to know if the add row function could be improved a little more.
I would like to add a control icon to a form that would allow the user to manipulate a table by growing it or shrinking it.
I am currently using this code to add a row if the answer is yes. This code duplicate the row and fills in the fields to match the existing row.
Sub SpecSheet_AddRow()
response = MsgBox("Add Additional Row?", vbQuestion + vbYesNo)
If response = vbYes Then
Dim rownum As Integer, i As Integer
ActiveDocument.Unprotect
Selection.Tables(1).Rows.Add
rownum = Selection.Tables(1).Rows.Count
For i = 1 To Selection.Tables(1).Columns.Count
ActiveDocument.FormFields.Add Range:=Selection.Tables(1).Cell(rownum, i).Range, Type:=wdFieldFormTextInput
Next i
Selection.Tables(1).Cell(Selection.Tables(1).Rows.Count, Selection.Tables(1).Columns.Count).Range.FormFields(1).ExitMacro = "SpecSheet_addrow"
Selection.Tables(1).Cell(Selection.Tables(1).Rows.Count, 1).Range.FormFields(1).Select
ActiveDocument.Protect Type:=wdAllowOnlyFormFields, NoReset:=True
End If
End Sub
This code has done well until somebody answered yes but meant to say no. Because this is a locked form, they couldn?t delete the added row and ended up sending a quote to a customer with a dead line?
I would like to see if the functions in InfoPath can be recreated in VBA. For licensing reasons, InfoPath isn?t available to me in this application.
Here is what I would like to try;
When the user is working in any cell on the row of a table. A control icon appears next to that row. If the cursor is clicked on the icon, a pull-down menu with a few options appears. These options would be to insert a new row above the current row, insert a new row below the current row, remove the current row and perhaps clear the current row.
I would like to make the form better, all suggested will be appreciated. I'm new to the VBA coding and I'm trying to learn. Please be patient and please anotate all the code so I can learn and understand.
I have attache an image to help see the idea.
TYIA
Richard