BorlandTalk.com Forum Index BorlandTalk.com
Borland discussion newsgroups
 
Archives   FAQFAQ   SearchSearch   MemberlistMemberlist   UsergroupsUsergroups   RegisterRegister 
 ProfileProfile   Log in to check your private messagesLog in to check your private messages   Log inLog in 

Word - CustiomizationContext

 
Post new topic   Reply to topic    BorlandTalk.com Forum Index -> Delphi OLE Automation
View previous topic :: View next topic  
Author Message
Marcin Junger
Guest





PostPosted: Thu Sep 21, 2006 1:55 pm    Post subject: Word - CustiomizationContext Reply with quote



Hello everyone,
I have another problem with Outlook using Word as editor. I create a
button on a Standard command bar. If Outlook does not use word,
everything works fine - the "temporary" parameter works and buttons are
not "remembered" after closing an inspector.
To do the same with word i am trying to:
1)save current customization context;
2)change customization context to current document;
3)do what I have to do;
4)restore customization context so changes made by user are permanent;

Sounds easy.
Here is my code from OnNewInspector event:

var
idWordEditor : Word97._Document;
idsCustomization : IDispatch;

(...)

//save current customization context and set it to current document
if Inspector.IsWordMail then begin
idWordEditor := IDispatch(Inspector.WordEditor) as _Document;
try
//the next line SOMETIMES raises an exception
idsCustomization := idWordEditor.Application.CustomizationContext;
except
idsCustomization := idWordEditor.Application.NormalTemplate;
end;
idWordEditor.Application.CustomizationContext := idWordEditor;
end;

try

(...)create button(...)

finally
//restore customization context
if Inspector.IsWordMail then begin
idWordEditor.Application.CustomizationContext := idsCustomization;
end;
end;

Apart from fact, that reading idsCustomization sometimes raises
exception, restoring it doesn't work. The code is executed and still in
View->Toolbars->Customize Save In=Untitled Message. If I don't change
the context by disabling idWordEditor.Application.CustomizationContext
:= idWordEditor; it is Normal.dot.

What do I do wrong?
Marcin
Back to top
Display posts from previous:   
Post new topic   Reply to topic    BorlandTalk.com Forum Index -> Delphi OLE Automation All times are GMT
Page 1 of 1

 
Jump to:  
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


Powered by phpBB © 2001, 2006 phpBB Group
SEO toolkit © 2004-2006 webmedic.