Activate a Word document loaded from within the add-in...

Add-in Express™ Support Service
That's what is more important than anything else

Activate a Word document loaded from within the add-in...
 
Heinz-Josef Bomanns




Posts: 201
Joined: 2008-02-28
Hi,

Word 2007 or 2010 starts up with an empty document. By a click on a ribbon button our WinForms dialog is invoked and shown modal with '.ShowDialog'. On some point the user can open a document choosen from a list within the dialog. We do this with 'Documents.Open' and the document loads fine. The problem is that it is not activated resp. not shown in the window behind our dialog, it stays minimzed in the taskbar and 'ActiveDocument' still references the first empty document. Tried something like 'currDoc = Documents.Open, currDoc.Activate' but that doesn't work. Any ideas anybody how to get the document activated behind our dialog? Thanks for any hints...
__________________
Greetings, HJB
Posted 11 May, 2012 04:30:15 Top
Eugene Astafiev


Add-in Express team


Posts: 8540
Joined: 2007-07-25
Hi Heinz-Josef,

May I see the code you use for opening documents in Word? I am interested in the parameters list you pass to the Open method of the Documents class from the Word Object Model.

BTW Could you please specify the build number of Add-in Express you have currently installed on the PC?
.NET, Extended MAPI, Windows Phone & RT
Posted 11 May, 2012 05:02:29 Top
Heinz-Josef Bomanns




Posts: 201
Joined: 2008-02-28
Hi Eugene,

Build is 6.6.3059 - before posting any questions i always make sure latest version is used and all available Service Packs and Hotfixes for Office are installed.

I don't have any special parameters, it's just a

gobjWord.Documents.Open(strFilename)


where 'gobjWord' is a global variable set to 'Me.HostApp' in the AddInModule and 'strFilename' points to an existing document in Word's default document directory...
__________________
Greetings, HJB
Posted 12 May, 2012 00:56:08 Top
Eugene Astafiev


Add-in Express team


Posts: 8540
Joined: 2007-07-25
Hi Heinz-Josef,

First of all, please note that you don't release underlying COM object properly. The Documents property of the Aplication class in Word returns an instance of the Documents collection which should be released after. You can read more about this in the When to release COM objects in Office add-ins developed in .NET article on our technical blog.

Also the Open method of the Documents class accepts a lot of parameters. Among them is the visible parameter which has the following description:

True if the document is opened in a visible window.


Please try to play with the parameters list. May be one of them will do the trick.
.NET, Extended MAPI, Windows Phone & RT
Posted 14 May, 2012 03:45:15 Top