View Single Post
  #2   Report Post  
Posted to microsoft.public.excel.programming
Ian Digby[_3_] Ian Digby[_3_] is offline
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