M
MikeZz
Hi,
I open a .rtf file in Word which I want to pull data from.
The document has a large number of similarly formatted tables of which I
want to put the data into an array.
In my Code below, I use the selection.find command to find a string which
only occurs in certain tables. After it finds and selects that cell, I want
to have VBA put that entire table into an array. Then repeat by doing
another search to find another table and do the same thing.
I do 99% of my VBA from excel and this particular macro is actually based
from an Excel Workbook. However, if someone can give me the basic VBA that
will work in VBA Word, I can figure out how to convert it to work from Excel.
Basic info I'm thinking would need....
(Keeping in mind that I don't know much about Word VBA)
How do I reference the current table?
How do I get the # of rows & columns of the active table,
Can I use some code like:
For r = 1 to activetable.rows.count
For c = 1 to activetable.cols.count
code to put cell(r,c) into array
Next C
Next R
Thanks for the help!
MikeZz
======= Section of MY EXISTING CODE ========
Set oWord = GetObject(, "Word.Application")
oWord.Visible = True
oWord.Activate
Dim myRange As Word.Range
Set myRange = ActiveDocument.Range
oWord.Activate
Set oDoc = oWord.ActiveDocument
oWord.Selection.Find.ClearFormatting
With oWord.Selection.Find
.Text = "Product/DRD FAM"
.Forward = True
.Wrap = wdFindContinue
End With
oWord.Selection.Find.Execute
'Selects the proper cell in a table.
'Now want VBA to put that entire table into an array.
I open a .rtf file in Word which I want to pull data from.
The document has a large number of similarly formatted tables of which I
want to put the data into an array.
In my Code below, I use the selection.find command to find a string which
only occurs in certain tables. After it finds and selects that cell, I want
to have VBA put that entire table into an array. Then repeat by doing
another search to find another table and do the same thing.
I do 99% of my VBA from excel and this particular macro is actually based
from an Excel Workbook. However, if someone can give me the basic VBA that
will work in VBA Word, I can figure out how to convert it to work from Excel.
Basic info I'm thinking would need....
(Keeping in mind that I don't know much about Word VBA)
How do I reference the current table?
How do I get the # of rows & columns of the active table,
Can I use some code like:
For r = 1 to activetable.rows.count
For c = 1 to activetable.cols.count
code to put cell(r,c) into array
Next C
Next R
Thanks for the help!
MikeZz
======= Section of MY EXISTING CODE ========
Set oWord = GetObject(, "Word.Application")
oWord.Visible = True
oWord.Activate
Dim myRange As Word.Range
Set myRange = ActiveDocument.Range
oWord.Activate
Set oDoc = oWord.ActiveDocument
oWord.Selection.Find.ClearFormatting
With oWord.Selection.Find
.Text = "Product/DRD FAM"
.Forward = True
.Wrap = wdFindContinue
End With
oWord.Selection.Find.Execute
'Selects the proper cell in a table.
'Now want VBA to put that entire table into an array.