Is there a way to not only read but also write from within MS Word to
There may be, but if there is, it certainly isn't as simple as it would be
in Word VBA on Windows. Although Mac Word VBA used to have similar
mechanisms for referencing libraries (cf. referencing .dlls on Windows) in
older versions of Mac OS, it isn't at all clear to me that it's possible
under Mac OS X.
Coming from the Windows side, you may in any case be unaware that the plan
is to drop support for VBA in the next version of Mac Word. Precisely what
you will be able to use is not so clear to me, except that it looks as if
you will be able to automate Word from outside using AppleScript.
Now to stuff I /can/ tell you:
a. you can't even use the Word MailMerge object to connect to an ODBC data
source as you can do on Windows. Mac Word 2004 simply doesn't have the
facilities.
b. you /can/ connect to ODBC data sources from Mac Excel 2004, but you will
need an ODBC administrator and a version of the MySQL ODBC driver that runs
on Mac (I don't have any additional detail for you there)
c. You /can/ automate Excel from Word VBA in much the same way that you can
do it from Word VBA on Windows.
d. assuming you have opened an ODBC database in an Excel Worksheet, here's
some code to do that sort of thing:
Sub GetODBCDataViaExcel()
Dim objExcel As Excel.Application
Dim objWorkBook As Excel.Workbook
Dim strWorkbookName as String
strWorkbookName = "Macintosh HD:Users:me
ocuments:query.xls"
' open the spreadsheet, refresh the table, and save the sheet
Set objExcel = CreateObject("Excel.Application")
Set objWorkbook = objExcel.Workbooks.Open(strWorkbookName)
objWorkbook.Worksheets(1).QueryTables(1).Refresh
objWorkbook.Close savechanges:=True
set objWorkbook = Nothing
objExcel.Quit
Set objExcel = Nothing
' Update all the fields in the body of the active Word document
ActiveDocument.COntent.Fields.Update
End Sub
That has the potential to retrieve the data, but as for maintaining it,
sorry, I never got that far.
Peter Jamieson