Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 39
Default Excel Got FOcus event

Hi All,

Iam writting an excel addin. I need to trap an event namely got focus for
the excel application. I tried it using the application events. But iam
unable to find a event when the excel application get focus or becomes
active . Is there any event like that.
Please help us.

Thanks in advance
Xcelion

  #2   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 15
Default Excel Got FOcus event

You can probably use the Workbook.Activate event: double-click the Workbook
module in the VBE, then select "Activate" from the right-hand drop-down list.
If you are trying to capture the event from outside Excel using the
Application object, you may need to create an Excel class within your
application, then create a WithEvents variable and assign the Excel App to it:

So within your class module (say it's called "CExcel"):
Dim WithEvents xlApp as object

Private Sub xlApp_Activate()
'Your code here...

End Sub

And within your code module:
Dim clsExcel as CExcel
Set clsExcel = New CExcel
Set clsExcel.xlApp = CreateObject("Excel.Application")

Now you should have access to the Excel Activate event.

--
Work performed in the spirit of service is worship...Baha''''i Writings


"Xcelion" wrote:

Hi All,

Iam writting an excel addin. I need to trap an event namely got focus for
the excel application. I tried it using the application events. But iam
unable to find a event when the excel application get focus or becomes
active . Is there any event like that.
Please help us.

Thanks in advance
Xcelion

  #3   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 39
Default Excel Got FOcus event

Hi ian,
This works fine when you are switching focus between two excel appliction
instances.But in my case i need to know for instance, when excel gets focus
from another application say word or when excel loses focus
Thanks
Xcelion






"Ian Digby" wrote:

You can probably use the Workbook.Activate event: double-click the Workbook
module in the VBE, then select "Activate" from the right-hand drop-down list.
If you are trying to capture the event from outside Excel using the
Application object, you may need to create an Excel class within your
application, then create a WithEvents variable and assign the Excel App to it:

So within your class module (say it's called "CExcel"):
Dim WithEvents xlApp as object

Private Sub xlApp_Activate()
'Your code here...

End Sub

And within your code module:
Dim clsExcel as CExcel
Set clsExcel = New CExcel
Set clsExcel.xlApp = CreateObject("Excel.Application")

Now you should have access to the Excel Activate event.

--
Work performed in the spirit of service is worship...Baha''''i Writings


"Xcelion" wrote:

Hi All,

Iam writting an excel addin. I need to trap an event namely got focus for
the excel application. I tried it using the application events. But iam
unable to find a event when the excel application get focus or becomes
active . Is there any event like that.
Please help us.

Thanks in advance
Xcelion

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
cursor focus in excel fourthhorn Excel Discussion (Misc queries) 1 June 2nd 06 06:05 AM
Is there a VBA Event to Detect Change in ActiveCell Focus? Larry A[_3_] Excel Programming 4 September 16th 05 03:23 AM
Excel stealing focus Akshay Excel Programming 3 October 24th 03 01:47 PM
event which occurs when a TextBox receives focus Mikhail Excel Programming 2 October 7th 03 02:27 PM
Excel 97 VBA: Multipage set focus method David Excel Programming 3 October 7th 03 01:55 PM


All times are GMT +1. The time now is 05:42 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"