Hello Tomaž

 

Many thanks for your patient explanation. I should have been able to work out 
for myself how the Word test works, and indeed I realized some of it when I 
came to shut down the Word instance and its two documents. But it was late at 
night, and I should have packed up before then.

 

My last test last night showed that basically I have cracked it for my job of 
automating Outlook. I have been able to connect to my running instance of 
Outlook, open my application and interrogate the names of my top-level folders. 
From now on it should be just a matter of understanding the MS documentation of 
the Outlook model.

 

However, all this is with Pharo-Com installed in a new Pharo 8 image. I have no 
idea what went wrong with my first effort on Pharo 7. But I shan’t worry about 
that – I shall gradually move all my bits and pieces to P8. I shall try to work 
it out myself from here, but I shall come back if I get stuck.

 

Thanks again

 

Peter Kenny

 

From: Pharo-users <pharo-users-boun...@lists.pharo.org> On Behalf Of Tomaž Turk
Sent: 06 April 2020 08:04
To: Any question about pharo is welcome <pharo-users@lists.pharo.org>
Subject: Re: [Pharo-users] Automation of MS Office from Pharo

 

Hello Peter,

 

If you look at the code in the Word test you will notice that the test firstly

- creates a new Word instance, 

- makes it visible to the end user, 

- then adds an empty document to the documents collection with the text "Hello 
from Pharo!"

- then it tests whether it can receive the same text back from Word.

 

After that, the test

- adds a new empty document to the documents collection with the text "Hello 
from Pharo! Some additional text. ", this time as an array of two texts

- it activates this second document (this imitates the end user's window 
activation on the desktop)

- then it tests whether it can receive the same text back from Word.

 

If you look at the Task Manager, you'll notice that you have one Word process 
with two open documents:

 



 

Namely, for each document Word creates a new, separate window - the documents 
are not displayed in one "Word application window", but separately - that's a 
normal behavior for some versions of MS Office, and it happens also if you open 
several documents directly in Word. So, there is just one Word instance.

 

'finalize' clears the references to the Word instance, it doesn't close the 
program by itself. If you want to do that, you can send Quit message to Word 
before you destroy the reference 
(https://docs.microsoft.com/en-us/office/vba/api/word.application.quit(method)).
 

 

Similar behaviour is with Outlook, here's one example: 
https://www.excelcommand.com/excel-help/excel-how-to.php?i=124116

 

The calling among COM objects is asynchronous, and it's usually wise to wrap it 
in error handling structures.

 

Please tell us how it goes.

 

Best wishes,

Tomaz

 

 

 

 

 

 

 

 

------ Original Message ------

From: "PBKResearch" <pe...@pbkresearch.co.uk <mailto:pe...@pbkresearch.co.uk> >

To: "Any question about pharo is welcome" <pharo-users@lists.pharo.org 
<mailto:pharo-users@lists.pharo.org> >

Sent: 5.4.2020 23:18:02

Subject: Re: [Pharo-users] Automation of MS Office from Pharo

 

Pablo - a final update before I close for the night. The Word test on the pharo 
8 version comes up green. The strange error message is nowhere to be seen in 
any Pharo 8 runs. The result is not what I expected; I finish up with two Word 
documents open, one with the first message, the other with the two messages. I 
thought the 'finalize' command would close it down.

 

Anyway, it looks as if I need to switch to P8 to use Pharo-Com. I shall 
continue testing tomorrow on P8.

 

Sorry for the late-night hassle.

 

Peter

 

Reply via email to