Home |
Search |
Today's Posts |
#1
Posted to microsoft.public.excel.programming
|
|||
|
|||
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
Posted to microsoft.public.excel.programming
|
|||
|
|||
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
Posted to microsoft.public.excel.programming
|
|||
|
|||
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 |
Display Modes | |
|
|
Similar Threads | ||||
Thread | Forum | |||
cursor focus in excel | Excel Discussion (Misc queries) | |||
Is there a VBA Event to Detect Change in ActiveCell Focus? | Excel Programming | |||
Excel stealing focus | Excel Programming | |||
event which occurs when a TextBox receives focus | Excel Programming | |||
Excel 97 VBA: Multipage set focus method | Excel Programming |