INFO: Techniques for Diagnosing/Resolving OLE Automation Err

ID: Q137029

The information in this article applies to:

SUMMARY

Applications using OLE Automation may encounter either one of the following two errors:

   429 - OLE Automation server can't create object
   438 - OLE Automation no such property or method

This article presents some techniques for resolving these errors.

MORE INFORMATION

Error 429

Error 429 typically occurs during a CreateObject call. There are several causes for this error:

Error 429: Low System Resources

Low system resources are a factor when CreateObject is used to load a specified application that doesn't already exist in memory. You can check system resources and memory at any time by clicking About Program Manager on the Help menu of the Windows Program Manager.

To test memory if you get error 429 in your Visual Basic code, switch to the Program Manager, and try to load the application. If you can't, you are low on system resources or memory. If you can, there may be a problem with either the syntax within CreateObject or with the registry.

Error 429: Corrupt or Invalid OLE Registry

If the OLE Registry is corrupted or invalid, you can use the following steps to restore it:

1. Exit windows. If you make these changes within Windows, they will be

   over-written. Windows stores the Registry in memory and writes it back
   out to disk when Windows exits.

2. Within the \Windows directory, make a copy of both Reg.dat and Win.ini
   files.

3. Delete the Reg.dat file.

4. Edit the Win.ini file, and remove the [Embedding] section.

5. Restart Windows. An empty Reg.dat file will be created.

6. Start File Manager. On the file menu, click Search, and find all files

   on your hard disk that have the .reg extension. That is, search for:

   *.reg

7. In the search results window, double-click the files that you want to
   add to the registry. You should, at minimum, double-click these files:

   Ole2.reg
   <YourApp.reg>

   Some applications will attempt to automatically re-register themselves
   on startup. The application will look for key entries in the registry;
   if none is found, the application will re-register itself. If the entry
   comes from a second application, this means the first application may
   not be properly registered. You may have to manually re-register each of
   your applications using the technique described in this step.

8. Retry your Visual Basic application.

Error 429: Lost Connection with the OLE Server

Finally, the connection to an object may have been lost. The following code can demonstrate how this can happen:

   Dim LoadDC as Object
   Dim LoadWd as Object
   Set LoadDC = CreateObject( "Word.Document.Doc" )
   Set LoadWd = LoadDC.Application.WordBasic
   Set LoadDC = Nothing
   LoadWd.FileOpen ...

As it stands, this code may generate error 429. If the third line of code setting LoadDC to nothing is removed or changed to a comment, it works.

Error 438

Error 438 can be generated when the OLE object created does not recognize the method or property you are attempting to use. This could be something as simple as a syntax error (the method or property you are trying to use is misspelled in your code). Or it could be because the object's connection is no longer available.

Consider the following scenario with OLE Automation between Visual Basic and Microsoft Word:

1. Start Microsoft Word, opening a specific document.

2. Print that document

3. Close the document by using FileClose.

4. Issue another Print command to the document.

This will generate error 438 because the link to the document was lost when it was closed. The syntax for issuing the print is correct but the method is no longer available because there is no document open within Word.

REFERENCES

The Office Developers Kit, currently shipping with Visual Basic, is an excellent resource for demonstrating how to use OLE Automation effectively with Visual Basic. It comes with a CD-ROM compact disc filled with technical information and reference material, as well as numerous samples.

For more information on how to obtain the Office Developers Kit, please see the following article in the Microsoft Knowledge Base:

   ARTICLE-ID: Q92545
   TITLE     : Visual Basic 3.0 Common Questions and Answers

Additional query words:
Keywords          : kberrmsg kbole kbVBp300 
Version           : 3.00
Platform          : WINDOWS

Last Reviewed: January 6, 1999