D
Doctorjones_md
What I'd done is this -- I have several forms which allow the user to make
selections, and the underlying code locates the data in a separate Word
Document and inserts that Row of data into a selected table in Document1
(Active Document). There are numerous Header Fields for the data a user my
select, so I opted to create all (13) tables in Document1, with the (2)
Header Rows and (1) blank Row. I need the following:
#1. I need to write the code that will examine the (13) Tables in
Document1, and Delete all tables without Data/Rows extending beyond
Row(3) -- how could I achieve this?
#2. I need to SUM columns 3-5 of all remaining Tables and show the values
in a Summary Table -- I went here for help:
http://word.mvps.org/FAQs/TblsFldsFms/TotalColumn.htm. I set my Bookmarks
in each of the Tables with Data to sum, and entered this code in the Summary
Table ({ SUM(Table1 F:F) \# "#,##0.00;- #,##0.00;''" }) -- for some reason,
I can't get this to work -- has anyone done something similar (ie, summing
columns from multiple tables into a Summary Row in a separate table)?
NOTE: The reason I opted for this method (over the
{ =SUM(ABOVE) } formula is because there may be blank, or Text-Filled cells
in these tables
Has anyone had any luck/experience doing something like this (ie, summing
columns of data from multiple tables into a Summary Row in a separate
table)?
Here's my Code: -- Much Thanks in Advance
Option Explicit
Dim pTable1 As Table
Dim pTable2 As Table
Dim pIndex As Long
Dim pRange As Word.Range
Dim ExportDoc As Word.Document
==================================
Private Sub cbxLinen_Click()
Set ExportDoc = Documents.Open("E:\Products\Linen.doc")
Set pTable1 = ExportDoc.Tables(1)
Set pTable2 = Documents("Document1").Tables(12)
If Me.cbxLinen.Value = True Then
Me.cbxNotIncluded.Value = False
pTable1.Rows.Add BeforeRow:=pTable2.Rows(3) 'Adds a NEW row in the
destination table -- active document
For pIndex = 1 To pTable1.Columns.Count
Set pRange = pTable1.Cell(7, pIndex).Range 'The row in the Table you
want to import
pRange.End = pRange.End - 1
pRange.Copy
pTable2.Cell(3, pIndex).Range.Paste
Next
Me.cmdOK.Enabled = True
End If
ExportDoc.Close
Set ExportDoc = Nothing
End Sub
selections, and the underlying code locates the data in a separate Word
Document and inserts that Row of data into a selected table in Document1
(Active Document). There are numerous Header Fields for the data a user my
select, so I opted to create all (13) tables in Document1, with the (2)
Header Rows and (1) blank Row. I need the following:
#1. I need to write the code that will examine the (13) Tables in
Document1, and Delete all tables without Data/Rows extending beyond
Row(3) -- how could I achieve this?
#2. I need to SUM columns 3-5 of all remaining Tables and show the values
in a Summary Table -- I went here for help:
http://word.mvps.org/FAQs/TblsFldsFms/TotalColumn.htm. I set my Bookmarks
in each of the Tables with Data to sum, and entered this code in the Summary
Table ({ SUM(Table1 F:F) \# "#,##0.00;- #,##0.00;''" }) -- for some reason,
I can't get this to work -- has anyone done something similar (ie, summing
columns from multiple tables into a Summary Row in a separate table)?
NOTE: The reason I opted for this method (over the
{ =SUM(ABOVE) } formula is because there may be blank, or Text-Filled cells
in these tables
Has anyone had any luck/experience doing something like this (ie, summing
columns of data from multiple tables into a Summary Row in a separate
table)?
Here's my Code: -- Much Thanks in Advance
Option Explicit
Dim pTable1 As Table
Dim pTable2 As Table
Dim pIndex As Long
Dim pRange As Word.Range
Dim ExportDoc As Word.Document
==================================
Private Sub cbxLinen_Click()
Set ExportDoc = Documents.Open("E:\Products\Linen.doc")
Set pTable1 = ExportDoc.Tables(1)
Set pTable2 = Documents("Document1").Tables(12)
If Me.cbxLinen.Value = True Then
Me.cbxNotIncluded.Value = False
pTable1.Rows.Add BeforeRow:=pTable2.Rows(3) 'Adds a NEW row in the
destination table -- active document
For pIndex = 1 To pTable1.Columns.Count
Set pRange = pTable1.Cell(7, pIndex).Range 'The row in the Table you
want to import
pRange.End = pRange.End - 1
pRange.Copy
pTable2.Cell(3, pIndex).Range.Paste
Next
Me.cmdOK.Enabled = True
End If
ExportDoc.Close
Set ExportDoc = Nothing
End Sub