Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 3
Default 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   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 400
Default 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
Search this Thread:

Advanced Search
Display Modes

Posting Rules

Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On


Similar Threads
Thread Thread Starter Forum Replies Last Post
Displaying MS Excel Chart control in ASP.NET Application oursmp Charts and Charting in Excel 0 April 20th 05 04:17 PM
User created control for use in Excel? Sandra[_5_] Excel Programming 1 February 9th 05 12:42 PM
application.run for returning arrays levent Excel Programming 3 July 23rd 04 08:01 PM
workbook and application reference set to null after the user enters something in an excel sheet Tobias[_3_] Excel Programming 0 May 19th 04 04:55 PM
How do I protect my hidden Excel.Application object from unwanted user interaction. wijwoj Excel Programming 0 October 30th 03 04:49 PM


All times are GMT +1. The time now is 03:44 PM.

Powered by vBulletin® Copyright ©2000 - 2024, Jelsoft Enterprises Ltd.
Copyright ©2004-2024 ExcelBanter.
The comments are property of their posters.
 

About Us

"It's about Microsoft Excel"