Recent

Author Topic: GetActiveOleObject fails even though CreateOleObject succeeds  (Read 2156 times)

RedOctober

  • Sr. Member
  • ****
  • Posts: 452
GetActiveOleObject fails even though CreateOleObject succeeds
« on: August 30, 2021, 03:11:21 pm »
Can some one explain what I am doing wrong?  After I successfully open IE from Lazarus, then I try to access it again later in code, I will get a "RPC server unavailable" error message.  In an attempt to overcome that error, I decided to try and "find" the Ole object by using GetActiveOleObject().  But that fails too... even immediately after the successful creation of the Ole object.

Code: Pascal  [Select][+][-]
  1.  
  2. uses  ... Windows, ComObj;
  3. ...
  4. Browser := CreateOleObject('InternetExplorer.Application');  // <--- this line succeeds
  5. Browser := GetActiveOleObject('InternetExplorer.Application');  // <--- this line fails
  6. ...
  7.  
  8.  

Error displayed:
Operation unavailable.
« Last Edit: August 30, 2021, 06:12:33 pm by RedOctober »

Jurassic Pork

  • Hero Member
  • *****
  • Posts: 1228
Re: GetActiveOleObject fails even though CreateOleObject succeeds
« Reply #1 on: August 30, 2021, 04:43:51 pm »
hello,
may be a problem with the internet explorer com object. 
With ms Word i have no problem with this code :
Code: Pascal  [Select][+][-]
  1. procedure TForm1.Button3Click(Sender: TObject);
  2. var msWord,sourDoc : OleVariant;
  3. begin
  4. msWord := CreateOleObject('Word.Application');
  5. msWord := GetActiveOleObject('Word.Application');
  6. sourDoc := msWord.Documents.Open('d:\temp\monDoc.doc');
  7. msWord.Visible := true;
  8. end;
maybe it is time to use other thing that internet explorer (end of life).  See this message

Friendly, J.P
Jurassic computer : Sinclair ZX81 - Zilog Z80A à 3,25 MHz - RAM 1 Ko - ROM 8 Ko

loaded

  • Hero Member
  • *****
  • Posts: 825
Re: GetActiveOleObject fails even though CreateOleObject succeeds
« Reply #2 on: September 09, 2021, 10:44:53 am »
may be a problem with the internet explorer com object. 
No problem, this is a precaution taken for security reasons.
You cannot connect to a session opened in Internet Explorer for security reasons, you can only access the session you started.
Check out  loaded on Strava
https://www.strava.com/athletes/109391137

 

TinyPortal © 2005-2018