1

I am using a Delphi app with an olecontainer to load a word document "OleContainer1.CreateObjectFromFile('c:\test\hello.docx', false);".

The ribbon functions perfectly well in the opened document until I open a different word document or activate another already open word document. When I return to the document in the Ole container the ribbon is disabled. I am unable to click on any of the buttons or change ribbon tabs. Even if I close the other word document the ribbon in the ole document remains disabled.

I am working on windows 10 with Word 2016

Cindy Meister
  • 25,071
  • 21
  • 34
  • 43
Mark Williams
  • 192
  • 2
  • 12

1 Answers1

2

The link provided by Cindy did in fact provide the answer with some tweaking. Many thanks. However, the link refers to Form activate and deactivate. If the ole application is in your main window then it needs to be handled in application events. If not in the main window then you need it in formActivate etc, but formActivate of a secondary form will not fire on application.activate so would need to also have code in application events which will tigger the formActivate of the secondary form. The following works for ole in main form and in Application onActivate

 var
    iO: IOleInPlaceActiveObject;
begin
  if not VarIsClear(App) then begin
    if Supports(OleContainer1.OleObject, IOleInPlaceActiveObject, io) then
      IO.OnFrameWindowActivate(true);
end;

Same in application deactivate but pass false as the param for onFrameWindowActvate

Cindy Meister
  • 25,071
  • 21
  • 34
  • 43
Mark Williams
  • 192
  • 2
  • 12