Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • Home
  • SEARCH
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 9138645
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 17, 20262026-06-17T09:17:01+00:00 2026-06-17T09:17:01+00:00

This is giving me a headache… The delphi App I’m working on opens one

  • 0

This is giving me a headache…

The delphi App I’m working on opens one or more forms with Word in a TOLEContainer. The problem I have is that when more than one form is opened with an embedded instance of Word, the controls of one instance affects all other instances whilst the controls on the first instance are unusable.

The controls for the first TOleContainer, for example, are still visible and appear to be enabled but are non-functional, selecting text in the first instance and using the controls in the second instance cause the changes to be reflected in first instance (clear as mud?!?) All very confusing so I’ve included a picture:

OleControls toolbar controlling both instances of word

The intention is to have each instance of word embedded in it’s own form and utilising it’s own controls. So what causes my undesired behaviour and what can I do about it? I’m sure it’s something simple, like catching the “activate” property and setting (I dont know what to set) of the OleContainer, but I’ve had no luck with this.

I figure one alternative might be to create my own instances of TWordApplication and either re-parent via Windows.SetParent() (this does work, btw, each instance does control itself but would require a lot of rework of the application) or embed in an OleContainer… can I embed TWordApplication instances their own OleContainers? If so how so? Alternatively changing the default open behaviour of CreateObjectFromFile (but I think this is controlled by the COM server which is Word)…

For reference…. Test the following by instantiating a couple of forms…

// This embed into an OleContainer, but opening two forms 
// leaves me with one that has working controls and another 
// that has non-working controls (this code on it's own form)
// If this code is on TForm2 and you create two instances of TForm2
// Word behaves incorrectly
OleContainer1.CreateObjectFromFile('C:\Test.docx', false);
OleContainer1.AutoActivate := aaGetFocus;
OleContainer1.DoVerb(ovOpen);

OleContainer1.Run;


//  To embed Word on a TPanel (this code on it's own form)
//  This code on TForm3, create two instance of TForm3 to see 
//  word work independently as desired
wordApp := TWordApplication.Create(Self);
wordApp.ConnectKind := TConnectKind.ckNewInstance;
wordApp.Caption := IntToStr(AppId);
wordApp.Visible := True;

WordHandle := FindWindow('OpusApp', PWideChar(wordApp.Caption));

Windows.SetParent(WordHandle, Panel1.Handle);

if AppId = 1 then
begin
  lFilename := 'C:\Test.docx';
end else begin
  lFilename := 'C:\Test2.docx';
end;
wordApp.Documents.Open(lFileName, EmptyParam, EmptyParam,EmptyParam,EmptyParam,EmptyParam,EmptyParam,EmptyParam,EmptyParam,EmptyParam,EmptyParam,EmptyParam);
  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-17T09:17:02+00:00Added an answer on June 17, 2026 at 9:17 am

    You could try working with IOleInPlaceActiveObject and activate and deactivate when your form activates and deactivates. See the accepted answer to my question: Context menu disappears with Word automation

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have this problem I'm working on which is giving me a headache, because
This problem is giving me a real headache. I have two tables in my
this one is really giving me a headache: using javascript (let's say on page1.html)
I understand the principle behind this problem but it's giving me a headache to
this is just weird and is giving me a headache. I looked over my
This is giving me a headache. I have this link query here that grabs
I Have a similar issue like the one listed here pointer-to-a-pointer-to-a-struct-giving-headache my issue is
this has been giving me a headache for a couple weeks now -- hope
My One step checkout is giving me a headache.. The dev console in IE
This is probably very basic, but it's giving me a headache, and I'm not

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.