OleContainer For MS Word

1.1k Views Asked by At

I have been using TOleContainer to display MS Word as an editor within my application. As from last week (3rd May 2022), the TOleContainer is not not embedding MS Word. Instead Word is opening as a separate screen:

enter image description here

If you close the form without closing ms word, an empty word container is left behind. And if you close MS Word, you cannot be able to reference the TWordDocument embedded in the TOleContainer

  1. This is happening for office 2016 and above.
  2. Tried removing all updates from last month to date to see if there is a windows update messing it up. No success.
  3. Tried with Delphi 7 & Delphi XE7 application but none is working.
  4. Only changing the office version to 2013 allowed it to work as before

Any assistance will be greatly appreciated.

3

There are 3 best solutions below

2
Olivier On

I had the same problem with office 365 et RAD Studio 11 (Delphi)

I just updated from office 2019 to office 365 and the problem occurred right after this update

I haven't found a solution so far.

Here is my Delphi code, which hasn't changed for 10 years and has always worked

  OleContainerWord.CreateObject('Word.Document', False);
  OleContainerWord.AllowInPlace := True;
  if OleContainerWord.State > osEmpty then
    OleContainerWord.DoVerb(ovShow);

If anyone has an idea, we're all ears :)

0
Pete1312 On

You could try adding the following into your application manifest and then re-compiling

<?xml version="1.0" encoding="UTF-8" standalone="yes"?>
<assembly xmlns="urn:schemas-microsoft-com:asm.v1" manifestVersion="1.0" xmlns:asmv3="urn:schemas-microsoft-com:asm.v3">
  <asmv3:application>
    <asmv3:windowsSettings>
      <dpiAware xmlns="http://schemas.microsoft.com/SMI/2005/WindowsSettings">true</dpiAware>
      <dpiAwareness xmlns="http://schemas.microsoft.com/SMI/2016/WindowsSettings">system</dpiAwareness>
    </asmv3:windowsSettings>
  </asmv3:application>
</assembly>

You would also need to set word to 'Optimize for Compatibility' Under File > Options > General

0
Eric Shoberg On

https://stackoverflow.com/questions/73134923/delphi-olecontainer-for-wps/73926149#answer-73926149

Try this answer.

I was internetting and decided to see if I could search up the answer, seems ya'll have the same problem.