In order to understand my questions let me give you some background detail that should help.
I've created a Mail Merge in Microsoft Word and converted it to Edit Individual Documents(this puts all records on one file separated by page break).
Below is a sample of what I'm using:
Dear James,
(TABLE BELOW)
Items Description Quantity
«Item_1» «Quantity_»
«Item_2» «Quantity_2»
«Item_3» «Quantity_3»
«Item_4» «Quantity_4»
----page break----
Dear Bob,
(TABLE BELOW)
Items Description Quantity
«Item_1» «Quantity_»
«Item_2» «Quantity_2»
----page break----
Dear Bob,
(TABLE BELOW)
Items Description Quantity
«Item_1» «Quantity_»
«Item_2» «Quantity_2»
«Item_3» «Quantity_3»
----page break----
What I am trying to show is that each table within the template email will not be the same. One template email might have 5 rows while the other might have 2 rows. The columns does not change. I was able to create a VB code that eliminate the rows that labeled "Remove", but my problem is that I have to run the macro one at a time for each table and also I have to change the VB code to reflect the table. For instance .Table(1), .Table(2), etc in the VB code(listed below).
Request:
Is there a way to have the VB code Loop through the file and remove the rows from all the table with the word "Remove" so i don't have to manually run the macro per table.
If possible instead of the word "remove", ideally I would prefer that the VB code remove any row that is blank from all table at once.
VB CODE that i use to remove the row manually:
Sub deletion()
With ThisDocument.Tables(1)
For r = .Rows.Count To 1 Step -1
fnd = False
For Each c In .Rows(r).Cells
If InStr(c.Range.Text, "REMOVE") > 0 Then fnd = True
Next
If fnd Then .Rows(r).Delete
Next
End With
End Sub
I've created a Mail Merge in Microsoft Word and converted it to Edit Individual Documents(this puts all records on one file separated by page break).
Below is a sample of what I'm using:
Dear James,
(TABLE BELOW)
Items Description Quantity
«Item_1» «Quantity_»
«Item_2» «Quantity_2»
«Item_3» «Quantity_3»
«Item_4» «Quantity_4»
----page break----
Dear Bob,
(TABLE BELOW)
Items Description Quantity
«Item_1» «Quantity_»
«Item_2» «Quantity_2»
----page break----
Dear Bob,
(TABLE BELOW)
Items Description Quantity
«Item_1» «Quantity_»
«Item_2» «Quantity_2»
«Item_3» «Quantity_3»
----page break----
What I am trying to show is that each table within the template email will not be the same. One template email might have 5 rows while the other might have 2 rows. The columns does not change. I was able to create a VB code that eliminate the rows that labeled "Remove", but my problem is that I have to run the macro one at a time for each table and also I have to change the VB code to reflect the table. For instance .Table(1), .Table(2), etc in the VB code(listed below).
Request:
Is there a way to have the VB code Loop through the file and remove the rows from all the table with the word "Remove" so i don't have to manually run the macro per table.
If possible instead of the word "remove", ideally I would prefer that the VB code remove any row that is blank from all table at once.
VB CODE that i use to remove the row manually:
Sub deletion()
With ThisDocument.Tables(1)
For r = .Rows.Count To 1 Step -1
fnd = False
For Each c In .Rows(r).Cells
If InStr(c.Range.Text, "REMOVE") > 0 Then fnd = True
Next
If fnd Then .Rows(r).Delete
Next
End With
End Sub