Plateforme Level Extreme
Abonnement
Profil corporatif
Produits & Services
Support
Légal
English
Bring Excel to front
Message
De
07/08/2013 19:02:18
Hilmar Zonneveld
Independent Consultant
Cochabamba, Bolivie
 
 
Information générale
Forum:
Visual FoxPro
Catégorie:
COM/DCOM et OLE Automation
Versions des environnements
Visual FoxPro:
VFP 9 SP2
OS:
Windows Server 2012
Network:
Windows 2008 Server
Database:
MS SQL Server
Application:
Web
Divers
Thread ID:
01580013
Message ID:
01580015
Vues:
60
Thanks. I tried the code for Excel, but it still won't come to the front. I don't get the error message, either. The code I used is:
LOCAL loShell
loShell = CreateObject ("WScript.Shell")
IF loShell.AppActivate (loExcel.Caption) = .T.
	loShell.SendKeys ("% ~")
ELSE
	MessageBox ("Application " + loExcel.Caption + " not found")
ENDIF
>>In the past, when I opened Excel through Automation (from Visual FoxPro), it came to the front automatically. I believe that was with an older version of the operating system. Now it doesn't. I suspect this has to do with some security system implemented by newer versions of the operating system itself, in which case not much can be done... but I wanted to check whether this is really the case.
>>
>>TIA,
>>
>>Hilmar.
>
>Check this solution http://forum.foxclub.ru/read.php?32,177182,258927#msg-258927
>
>
>Приложение Excel 
>  
> * Создание экземпляра приложения Excel  
>  LOCAL loExcel as Excel.Application  
>  loExcel = CreateObject("Excel.Application")  
> * Далее идет создание и заполнение документа  
>  ...  
> * Сформированный документ делается видимым  
>  loExcel.Visible = .T.  
>    
> * Выводится экземпляр приложения Excel на передний план  
>  LOCAL loShell  
>  loShell=CreateObject("WScript.Shell")      
>  IF loShell.AppActivate(loExcel.Caption) = .T.    
>  	loShell.SendKeys("% ~")    
>  ELSE    
>  	MessageBox("Приложение "+loExcel.Caption+" не найдено")    
>  ENDIF
>
>Однако в отношении Word или Excel есть специфический способ активизации, основанный на том, что разворачивание этого окна на максимум из свернутого (минимизированного) состояния автоматически приводит к его активизации. 
>
>Приложение Word 
>  
> * Выводится экземпляр приложения Word на передний план  
>  #DEFINE wdWindowStateMinimize 2  
>  #DEFINE wdWindowStateMaximize 1  
>    
>  loWord.WindowState = wdWindowStateMinimize	&& Сворачиваем окно  
>  loWord.WindowState = wdWindowStateMaximize	&& Разворачиваем окно, что приводит к его активизации  
>
>Приложение Excel 
>  
> * Выводится экземпляр приложения Excel на передний план  
>  #DEFINE xlMinimized -4140  
>  #DEFINE xlMaximized -4137  
>    
>  loExcel.WindowState = xlMinimized	&& Сворачиваем окно  
>  loExcel.WindowState = xlMaximized	&& Разворачиваем окно, что приводит к его активизации  
>
>
>I've translated this before, don't have time right now.
Difference in opinions hath cost many millions of lives: for instance, whether flesh be bread, or bread be flesh; whether whistling be a vice or a virtue; whether it be better to kiss a post, or throw it into the fire... (from Gulliver's Travels)
Précédent
Suivant
Répondre
Fil
Voir

Click here to load this message in the networking platform