You need to connect to some office application via ole (say, to word), what do we do in this case? It's simple, put the CreateOleObject('Word.Application') expression into the variable of the Variant type and continue on. But it only seems so. It does not recognize the CreateOleObject procedure, it safely gives an error - the compilation is interrupted. Now we climb into Delphi 7 we open the project created in Delphi XE ... after a short swearing (short, because the project is an empty form) the program will CreateOleObject safely, CreateOleObject works fine. But we don’t stop there - again we climb into Delphi XE, open the recompiled project - and again everything is great. No new modules are connected, what is happening is not clear.

That is, in the end everything works, but surely this could be achieved by other methods. I would like to know what I am doing wrong and what to do. OS - Windows 7 Ultimate x64 (if that matters).

  • 2
    In general, when working with automation, you must use OleVariant, not Variant. - karmadro4
  • Thanks, I will consider - Bran

1 answer 1

Everything is much simpler: just plug in the ComObj module.

  • O_O Thank you very much, it helped! Everything turned out to be really simple :) The fact is that for some reason, in the version I described, delphi 7 did not connect comobj, so I thought ... - Bran
  • In delphi 7, CreateOleObject in another unit was (I don’t remember which one it was connected to by default), and ComObj is an intermediate type solution to facilitate the transition to XE and further, I came to this rake in the 2010 version. - Vahan Av