Home |
Search |
Today's Posts |
#1
Posted to microsoft.public.excel.programming
|
|||
|
|||
Returning User Control to Excel from other Application in VBA
Hi.
I'm using Excel VBA to control both Excel and another application. However, there are times when I want to control whether Excel or the other application is the 'active' application and the one displaying on the screen. (I pop up a user form in Excel, but the user has to click Excel in the windows toolbar to activate it before they see the form). How do I return control back to Excel from the other application? Thanks! |
#2
Posted to microsoft.public.excel.programming
|
|||
|
|||
Returning User Control to Excel from other Application in VBA
An API call may give you the control you seek:
Declare Function SetActiveWindow Lib "user32.dll" (ByVal hwnd As Long) As Long If you are using Excel 2003, hwnd is a property of the application object. For the other application (and other versions of Excel), you need to find its HWND property. If it is not an exposed property, use the API call FINDWINDOW: it MAY give you its handle: Declare Function FindWindow Lib "user32" Alias "FindWindowA" (ByVal lpClassName As String, ByVal lpWindowName As String) As Long PS: the lpclassname for Excel parameter for ALL versions of Excel is XLMAIN. " wrote: Hi. I'm using Excel VBA to control both Excel and another application. However, there are times when I want to control whether Excel or the other application is the 'active' application and the one displaying on the screen. (I pop up a user form in Excel, but the user has to click Excel in the windows toolbar to activate it before they see the form). How do I return control back to Excel from the other application? Thanks! |
Reply |
Thread Tools | Search this Thread |
Display Modes | |
|
|
Similar Threads | ||||
Thread | Forum | |||
Displaying MS Excel Chart control in ASP.NET Application | Charts and Charting in Excel | |||
User created control for use in Excel? | Excel Programming | |||
application.run for returning arrays | Excel Programming | |||
workbook and application reference set to null after the user enters something in an excel sheet | Excel Programming | |||
How do I protect my hidden Excel.Application object from unwanted user interaction. | Excel Programming |