 |
BorlandTalk.com Borland discussion newsgroups
|
| View previous topic :: View next topic |
| Author |
Message |
Kris De Decker Guest
|
Posted: Thu Jan 22, 2004 3:26 am Post subject: Tips on Word Automation exceptions |
|
|
Hello,
After registering some Office 2003 type libraries (without installing Office
2003) my Word ole-automation code did not work anymore. I have three
versions of Office on my PC - Office 97, Office 2000, Office XP. The
ole-automation code worked with the different versions of Word before
registering the Office 2003 type libraries. I concluded that the registering
the Office 2003 type libraries (using regtlib) was the cause of the problem.
I was on a mission to find out what had changed so I could revert to a
previous state. Here is a list of the actions I took in order to revert my
system to a previous state.
-Uninstalled/Reinstalled the different office versions
-Started WinWord.exe from the commandline using the /R option. That should
reregister the Word registry entries.
-Registered the old office version type libraries using the regtlib utility
None of this operations reverted my system to the old state. Whenever I try
to open Word using the following line:
FWordApplication2K := Word2000.TWordApplication.Create(Self);
I received the dreaded "interface not supported" exception
I also tried late binding using the following code:
CreateOleObject('word.application.10')
But it resulted in the same dreaded "interface not supported" exception
Deborah has a nice explanation of the actual behind the scenes operations
when Early/Late binding calls are made in Delphi >>
http://groups.google.com/groups?hl=en&lr=&ie=UTF-8&oe=UTF-8&selm=VA.0000098e.0265bd81%40cableinet.co.not-this-bit.uk
The strange thing was that Word would always start >> so something was being
executed. I deduced that the Office 2003 type libraries were still 'active'
and were overriding the previous Office version type libraries. Since I
didn't have Word 2003 on my system >> the interface could not link to the
actual code >> I got an 'interface not supported' exception. I wanted to
make sure that was the case so I used MS OLE viewer utility. OLE viewer is a
free download and is only 154 KB small but it is the tool to examine a
system to see what is actually in the registry. Yes you could go straight to
the registry and find the same information but the OLEViewer is much more
userfriendly and gives a much better overview. Take a look at this
screenshot >>
http://www.project-beheer.be/blog/Articles/Nytro/OLEViewer.html
There I discovered that the Word 2003 interface was still registered. Since
the Word 2003 had the highest version number it would handle all the Word
OLE calls >> and try to start the non-existing Word 2003 exe >> call would
fail >> interface not supported exception would be raised. I manually
unregistered the MSWorld.olb (2003) files using the regtlib utility with
the -u option. After unregistering the OLE viewer correctly showed the Word
libraries installed on my system. So I thought the my Word mailmerge code
would work once again. But the changes did not solve the problem >> the code
would still throw the exception. I looked in the newsgroups and found the
following article:
http://groups.google.com/groups?q=new+installation+of+the+NT-object-environment&hl=en&lr=&ie=UTF-8&oe=UTF-8&selm=3A83BC08.4A321591%40kzvth.ef.uunet.de&rnum=1
Apparently Dietmar was able to solve the same problem by reenabling the
Visual Basic Environment (VBE). I reregistered the C:Program FilesCommon
FilesMicrosoft SharedVBAVBE.DLL using regsvr32. After this command my
code worked, tanx Dietmar :)
Conclusion:
-In case of COM related problems use the OLEViewer to ensure that the
correct typelibraries are registered.
-Experimenting with late and early binding might give an indication why the
problem is occuring
-Make sure VBE is correctly registered on the PC
Hopefully this post will save some people some time :)
Regards,
Kris De Decker
____________________________
http://www.project-beheer.be
|
|
| Back to top |
|
 |
|
|
You cannot post new topics in this forum You cannot reply to topics in this forum You cannot edit your posts in this forum You cannot delete your posts in this forum You cannot vote in polls in this forum
|
|