Hannes Koidl
Posts: 320
Joined: 2008-05-19
|
Hi Guys,
today i ran in exactly this Problem:
http://support.microsoft.com/kb/261158
It happens when you add an ContextMenu to Word, and in the ClickEvent you call:
wordApplication.ActiveDocument.Close(ref saveOption, ref originalFormat, ref omissing);
If this is the last Document you get the AccessViolation. I just updated my Office PIA's to the 2003 Version - but still without success.
Has someone an suggestion what i can do here?
Or if you have an better Idea how i can handle this one: I need to process the current Document into an DMS System. For this i need to read the File, thats why i need to close the current Document, read it with an FileReader, and then reopen it. I didnt found an way to save the ActiveDocument in an Temp Path - because when i call SaveAs() - the document gets the Active one?
thx
Hannes |
|
Andrei Smolin
Add-in Express team
Posts: 18794
Joined: 2006-05-11
|
Hi Hannes,
Try using the SendMessage method and OnSendMessage event of your add-in module. This allows executing this code line a) after a small delay and b) not in the Click event.
Andrei Smolin
Add-in Express Team Leader |
|
Hannes Koidl
Posts: 320
Joined: 2008-05-19
|
Hi Andrei,
thx for the good suggestion. Do you mean in the Click Event i to a SendMessage("MyMessage") and in the OnSendMessage i call my Code with the Close Method?
Do you know why this Problem still exists?
thx
Martin |
|
Andrei Smolin
Add-in Express team
Posts: 18794
Joined: 2006-05-11
|
Hi Martin,
Do you mean in the Click Event i to a SendMessage("MyMessage") and in the OnSendMessage i call my Code with the Close Method?
Yes, this way exactly.
Do you know why this Problem still exists?
I don't know. I suppose. They didn't expect someone closing the document from a context menu item.
Andrei Smolin
Add-in Express Team Leader |
|
Hannes Koidl
Posts: 320
Joined: 2008-05-19
|
I don't know. I suppose. They didn't expect someone closing the document from a context menu item.
Parhaps they should :) I just need to close it temporary to make a copy of the current Doc.
The SendMessage Trick did it Sergey - thx! |
|