Art Delphi Automation History Home Politics Email me Default Colours Printable Colours
For specific programs, follow the links:
Access Binder Excel Outlook PowerPoint Word
General hints for Office automation
See also my introduction to automation, and Using Delphi 5's server components.
|Web sites|| Delphi sites
Binh Ly's tutorials
Earl F. Glynn's tips pages
|Books||Charlie Calvert's Delphi 4 Unleashed|
If you're automating Microsoft Office, you're in luck.
For one thing, the most commonly automated programs are probably Word and Excel, followed by Outlook, and so there's some Delphi code out there showing you how to do it. (See the pages for the specific programs for links.)
For another, the Record Macro facility of programs like Word and Excel is really useful for the automation programmer. If you don't know how to do something from Delphi, just record yourself doing it in Word and then edit the macro to see what you did.
Then there are special VBA helpfiles for these applications, which helps, too. Admittedly they aren't installed by default - you have to choose them specially in the Office setup program. And, as helpfiles, they sometimes leave a certain amount to be desired. But they're a lot better than nothing. I suggest putting them on your Office shortcut bar - you'll find you use them a lot.
But of course, there are drawbacks in Office automation, too. Visual Basic for Applications, for example.
All the examples in Microsoft's help files are in VBA, so it pays to make yourself familiar with it. Here are some things to watch out for when you're copying an example:
The last four points can be seen in this conversion from VBA to Delphi:
|Delphi||(Excel.Selection[LCID] as Range).End_[xlDown].Select;|
But don't worry - it's usually more straightforward than this!
WaitForApp component - component with an event to inform you when an Office app closes. This is helpful with Excel, which has no OnQuit event, and Word97, which has a buggy one.