Plateforme Level Extreme
Abonnement
Profil corporatif
Produits & Services
Support
Légal
English
Problem with closing Excel opened by automation
Message
Information générale
Forum:
Visual FoxPro
Catégorie:
Gestionnaire d'écran & Écrans
Versions des environnements
Visual FoxPro:
VFP 8 SP1
OS:
Windows XP
Database:
Visual FoxPro
Divers
Thread ID:
01232734
Message ID:
01233552
Vues:
10
>Naomi,
>
>I test in my command window and I do not need ShowWindow after BringWindowToTop, this code works fine for me
>
>
>DECLARE SHORT BringWindowToTop IN WIN32API INTEGER HWND
>
>loExcel			= Createobject('Excel.Application')
>loExcel.Visible		= .T.
>
>BringWindowToTop(loExcel.Hwnd)
>
>

Hugo,

Without even trying I can say, this test is inefficient. E.g. create a test form with two command buttons: one for opening file (!) with Excel and another to bring it to front. Save Excel refrence to form's property. You need to have something in between to have time to minimize Excel. Also in my tests first time it worked, but then it stopped, so I got a tip of using ShowWindow after BringWindowToTop from Alex Weider message.

Here is the idea of my code:

If I found, that the file I want to create is currently opened by Excel, I want to bring Excel to front, let the users close it, and then proceed with creating Excel and opening it again.

So, in my tests: I create Excel file, minimize it.

Then a separate method checks, if file can be created (BTW, why do I need to go with fopen and not try/catch - strange?).

Anyway, I hope you're following my idea.

>Sorry about the Sleep code, I do not understand what you need to do there, but... I have an idea, let me test it and I come back to you.
>
>>Hugo,
>>
>>Good point, thanks. One less API call. I found I still need ShowWindow after BringWindowToTop though.
>>
>>Still it doesn't help with sleep/do while code. Do you have more ideas?
>>
>>Thanks again for the Excel hwnd suggestion.
If it's not broken, fix it until it is.


My Blog
Précédent
Suivant
Répondre
Fil
Voir

Click here to load this message in the networking platform