We have a Windows application that loads a Word Document scans the text for
tokens which it then talks to a database on another server to get the values
to substitute. I'm not a Windows person but I think it may be using
something called COM (or OLE or MS Type Library).
Can I do the same on Mac OS X? I have to use Objective-C as this is part of
a much larger application. I've struggled to find any Mac documentation on
doing thins kind of thing.
You won't be able to talk to Word via Objective-C, the main language of
Cocoa. Word is Carbon, not Cocoa. (And its APIs are not available, they're
proprietary, so you wouldn't be able to do much in Word using C++ or C
either.)
There are two higher-level languages available to you: VBA, which is also
operative in Windows and which should (I think) be accessible form straight
VB on Windows. Or AppleScript. If you are accessing just the new Word 2004,
then the AppleScript dictionary is complete and dependable. If you want also
to access earlier Word Mac versions (where the AppleScript dictionary is
corrupt and undependable) you'll have to use 'do Visual Basic' command,
which fundamentally means accessing VBA via AppleScript:
http://word.mvps.org/FAQs/WordMac/WordAppleScript.htm
If you really need to do this from Objective C, you could do it first as
AppleScript (meaning probably 'do Visual Basic') and save the script as a
compiled script or text. Then you can access and run it form Obj-C: check
out NSAppleScript in ApplicationKit.
That's a very roundabout way: Obj-C translating AppleScript translating VBA.
Can't you just do it directly from the Windows app using VBA? (To the best
of my knowledge, which is poor here, VBA is a type of .COM. VBA is a
high-level layer on top of OLE Automation.)
--
Paul Berkowitz
MVP Entourage
Entourage FAQ Page: <
http://www.entourage.mvps.org/faq/index.html>
AppleScripts for Entourage: <
http://macscripter.net/scriptbuilders/>
Please "Reply To Newsgroup" to reply to this message. Emails will be
ignored.
PLEASE always state which version of Entourage you are using - **2004**, X
or 2001. It's often impossible to answer your questions otherwise.