This is really continuation from "thread707-926686".
The code I am using now sort of works but still pastes in the wrong location and have not been able to correct that.
Also it erases the bookmarks from the actual Word document and therefore only works once and not indefintely.
And last but not least then in the third table that I do need to add another row to, it runs into a "vertically merged table" and chokes (runtime error 5991).
I have two command buttons in the document that activates and run the VBA code separately for each user initiated function.
Does it make any difference whether or not these macros are in "this Document" or as separate modules, ie Module1 etc.?
Could really use some help with this as I am unable to get it working (am too VBA challenged I guess)
Here is my present code:
thanks for your help in advance
The code I am using now sort of works but still pastes in the wrong location and have not been able to correct that.
Also it erases the bookmarks from the actual Word document and therefore only works once and not indefintely.
And last but not least then in the third table that I do need to add another row to, it runs into a "vertically merged table" and chokes (runtime error 5991).
I have two command buttons in the document that activates and run the VBA code separately for each user initiated function.
Does it make any difference whether or not these macros are in "this Document" or as separate modules, ie Module1 etc.?
Could really use some help with this as I am unable to get it working (am too VBA challenged I guess)
Here is my present code:
Code:
Sub NewRows()
Dim mTable As Table
Dim r As Range
Dim myFields(2) As String
Dim i As Integer
ActiveDocument.Unprotect Password:="MES3052D"
' these are the three formfield names
myFields(0) = "DocAffText32"
For Each mTable In ActiveDocument.Tables
' go to bookmark, just to make sure
' in the right table, then collapse
Selection.GoTo what:=wdGoToBookmark, Name:=myFields(0)
Selection.Collapse Direction:=wdCollapseStart
' set range object as last row in table
' make the Selection the range end
Set r = ActiveDocument.Tables(i + 1).Rows(ActiveDocument.Tables(i + 1).Rows.Count).Range
Selection.Start = r.End
' copy range and paste it
r.Copy
r.Paste
' release range object
Set r = Nothing
i = i + 1
Next
ActiveDocument.Protect (wdAllowOnlyFormFields), Password:="MES3052D"
End Sub