Maybe the user has Word open while running your code so you can't really close Word. What you need to do it try to close it using TRY ELSE CATCH.
Main Topics
Browse All TopicsI have a VFP-9 application on a network of about 10 users that uses a Word Application object to perform a mail merge, update a mail-merge document, print it and save it to a NEW document. The users select a master mail-merge document from a folder of documents and then process the merge-print-save. The data source for the mail-merge is a CSV file that is stored on each users local hard-drive. This CSV file is updated before each merge.
Very often error #1429 OLE IDispatch exception code 0 from Microsoft Word: is issued.
After the above message it says Requested object is not available...
-OR-
This file is read-only. (F:\COLLECT\DOCS\51 CORP DEMAND.doc) [the master documents name
-OR-
Word cannot save this file because it is already open elsewhere. (F:\DEBTOR-DOCS\...\MEM-PB
The #1429 error message has been issued with Requested object is not available... even when no other programs are running on the workstation and no other users are logged in.
Everything works in testing and sometimes, it also works in the live environment. It almost seems that a document and/or the Word object is being left open, but I ran it with the Processes page on the Windows Task manager open and I could see Winword open and then close.
The code is below.
Users are running VFP-9 (compiled EXE application), Windows-XPP, Word-2003.
Any help would be greatly appreciated.
Also, does anyone know of a GOOD source for VFP Office Automation, as every time I need to use it I end up winging it (very time consuming).
Thank you all.
This Question has been solved and asker verified All Experts Exchange premium technology solutions are available to subscription members.
Experts Exchange has been collecting answers to technology questions since 1996…3 million and counting! If you have a question, chances are we already have your answer.
If you can't find the exact answer you're looking for, ask our exclusive community of 50,000 experts. You’ll get a personalized answer from a trusted professional.
Thousands of free tech tips, tricks, how-to’s and tutorials are available in our peer reviewed articles section. See for yourself how smart our experts are, no login required.
Access the answers to your technology questions today.
30-day free trial. Register in 60 seconds.
Members of the expert community talk about why the experience at Experts Exchange is different than what you will find anywhere else.

Try it out and discover for yourself.
30-day free trial. Register in 60 seconds.
Join the community of experts here and help other tech pros by answering question in your area of expertise. You can earn FREE access to all Experts Exchange's premium features and resources.
Office automation is as hard or easy as other programming. The thing you need to be aware of, is that you automate an external process with it's own rules and language and object model. If Office is installed correctly it works "as expected". ERROR 1429 or 1427 are OLE errors, that themselves are not always the same error, it's a whole list of errors coming in as that error VFP, take a look at AERROR and what it says about the iformations you get in the error array when these errors ar thrown from OLE.
When you get a "Requested object is not available..." error and you're sure it is available, then this could have several reasons: a) You think about the wrong object being complained about, eg OLE talks about the OLE server word.application or something else in regard to mailmerge, while you think of a document. b) Office is simply not installed correctly, which can surely and simply happen, if something else is deinstalled and deleted some portion of shared DLLs needed by Office. Office is not a simple EXE as you surely know, it's vulnerable as a complexer system c) The error may be misleading and something else is wrong.
Either way, if it works during development and you didn't forgot to distribute any third party components or plug ins needed, you should simply try with a complete deinstall, cleanup and reinstall of Office.
If you have have different Office version, that also could be the simple reason. While Office often is compatible, that is only downward compatibility. Eg if you develop with a higher version than used, don't complain about things missing or not working, that were only introduved in the newer version.
Bye, Olaf.
Business Accounts
Answer for Membership
by: pcelbaPosted on 2009-08-28 at 01:52:26ID: 25205807
Yes, Office automation is unstable sometimes... Or maybe not unstable but unpredictable. And it is hard to help to fix all possible problems you could have.
m/catalog/ autofox.ht m
What I would try to do in your situation is to find some work around. It seems your problems are not reproducible each time but you know almost all error states. In such cases you should try to solve your problems in error handler. You may RETRY the command which caused error known from your list after some (one second) delay. It should allow to finish all pending Windows events and the operation could then be successful... You may do it in a loop and rise the error after, let say, three attempts. But who knows if it will help?
You are writing "everything works in test environment". Does the EXE executed under run-time library work in your test environment? Always? Then you should look for differences between your test and production environment. Or did you try to execute your app under VFP development version in your production? Does it produce same errors?
The good source for VFP office automation is here:
http://www.hentzenwerke.co
But don't expect it will solve your problems :-). Yes, there are some very useful hints in this book and it points to known issues in office automation but your problems will probably need "something more"...
Good luck!