
Access VBA Calling MSWord/Excel VBA?
Lets clear up a few things, and then lets look towards a solution:
Quote:
>> using version 97 of word, excel and access and do not have Visual Basic
> (which I suspect could "pull" this all together!).
Excel, Word, and ms-access all have VBA. Not sure why you think Excel does
not have VBA. (just try hitting alt-f11 while in word, or excel..you will
see the full VBA environment in both of the products). Ms-access also have
VBA, but does not have VB forms like Excel, and word does.
Regardless, you can probably run the whole process from ms-access, and skip
Excel all together. (so, yes, you can call/run the word code form
ms-access). In fact, I would use the code you have for word now, and move it
into ms-access. It could process all the documents, and grab the data. This
will work *if* the word results are in a reasonable table format. If the
data is NOT structured, and you have to massage the data in Excel, then this
may not work. It really depends on how nice the data from word is. If you
have to do a lot of manual re-formatting in Excel, then things get
difficult.
Quote:
> 1. Open word, run word VBA routine
> 2. Open Excel, do manual copy paste from Word, save
> 3. Open Access, VBA to import Excel file
If the data in word is in a table, then you can in ms-access open that word
doc, and take data from the table:
The code can look like:
Dim MyWord As Word.Document
Set MyWord = GetObject(strWordDoc)
' move to the table in word doc
MyWord.GoTo wdGoToTable, wdGoToFirst, 1
' now get the next 9 entries from the table and
' stuff them into our array
For i = 1 To 9
MyWord.ActiveWindow.Selection.MoveRight wdCell, 2
'colHold.Add MyWord.ActiveWindow.Selection, CStr(i)
mybuf(i) = MyWord.ActiveWindow.Selection
Next i
MyWord.ActiveWindow.Close wdDoNotSaveChanges
Set MyWord = Nothing
' at this point our string array has 9 values in it..
The above would need more work to grab the "next" line of the table data,
but it certainly can be done. Thus, you can get ms-access to open the word
docs, and grab all the data
Here is for example some code in ms-access that opens a word doc, reads the
table data from word right into a table in ms-access.
--
Albert D. Kallal
Edmonton, Alberta Canada
http://www.attcanada.net/~kallal.msn