Embedded word document Issue

DeepUnderground
07-10-2010, 05:44 PM
Hello,

I have a sammple spreadsheet that I have attached. I have an interesting issue.

In the spreadsheet, I have an embedded word document. The spreadsheet will automatically transfer information to the word document.

In the ChangeHeaderInfo routine I have the code: Worksheets("Sheet1").OLEObjects(1).Activate

This needs to be executed once before I can actually put information into the word document.

Once it is executed, it does not need to be executed again for information to be passed into the word document.

Does anyone know why this is?

Insomniac
07-12-2010, 07:48 AM
It has to do with initializing the server for OLE object, in this case Word.

You can try the Verb Method instead of Activate, but the result is the same, ie you see the object activate. (Even with ScreenUpdating set to False as you see Word Initialize)
http://msdn.microsoft.com/en-us/library/bb238045(v=office.12).aspx

I added this code:Worksheets("Sheet1").OLEObjects(1).AutoLoad = True
http://msdn.microsoft.com/en-us/library/bb237188(v=office.12).aspx

Also read here for OLEObject Object Members
http://msdn.microsoft.com/en-us/library/bb242385(v=office.12).aspx

I found once I made AutoLoad = True and save the workbook you dont need to set it again and can remove your OLEObjects(1).Activate code.

DeepUnderground
07-12-2010, 02:35 PM
It works, but if I have OLE objects on different worksheets, I have to unload the object on the previous sheet before I load the next object.

EZ Archive Ads Plugin for vBulletin Copyright 2006 Computer Help Forum