Handle excel events in Access

JFKjr

New Member
Joined
Jul 25, 2008
Messages
7
Hello everyone, my problem seems to be simple but it is giving me very hard time to resolve.

I have an excel file with "Worksheet_BeforeDoubleClick" event defined in excel vba and this event is automatically called whenever a user double clicks on a cell. The event is working perfectly fine in excel.

But my problem is, I would like to open an excel file through Access VBA and call the event automatically whenever a user double clicks on a cell in the excel.

Well, the following Access VBA code opens an excel file successfully when I run "RunMacro()" proc. But, the proc calls the event only once when I run it.

The code doesn't call the event automatically whenever the user double clicks on a cell!
Code:
Sub RunMacro()
Dim xlApp As Excel.Application
Dim xlWB As Excel.Workbook
Set xlApp = New Excel.Application
 
With xlApp
.Visible = True
.Interactive = True
Set xlWB = .Workbooks.Open("C:\Books1.xls", , False)
xlWB.Worksheets(1).Activate
Worksheet_BeforeDoubleClick ActiveCell, False
End With
Exit_Routine:
Set xlApp = Nothing
Set xlWB = Nothing
Exit Sub
End Sub
Code:
Private Sub Worksheet_BeforeDoubleClick(ByVal Target As Range, Cancel As Boolean)
MsgBox "Hello!"
End Sub
I am really having very haaaaard time to solve this problem. Its been two weeks I have been working on this problem.

I have also searched internet a loooooot, but I haven't find anything on "handling excel events in access".

Please have mercy on me. Your help/idea will be greatly appreciated. Thanks a hundred billion in advance!
 

Excel Facts

Repeat Last Command
Pressing F4 adds dollar signs when editing a formula. When not editing, F4 repeats last command.
Hi, the event will need to be within the Excel workbook your opening. Assuming this is the case, try adding the line DoEvents before opening Excel and see if this makes any difference.

hth,
Graham
 
Upvote 0
Hello Graham, thanks for the reply.

I was able to handle excel events in Access using "WithEvents".

Thanks anyway though :)
 
Upvote 0

Forum statistics

Threads
1,216,126
Messages
6,129,016
Members
449,480
Latest member
yesitisasport

We've detected that you are using an adblocker.

We have a great community of people providing Excel help here, but the hosting costs are enormous. You can help keep this site running by allowing ads on MrExcel.com.
Allow Ads at MrExcel

Which adblocker are you using?

Disable AdBlock

Follow these easy steps to disable AdBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the icon in the browser’s toolbar.
2)Click on the "Pause on this site" option.
Go back

Disable AdBlock Plus

Follow these easy steps to disable AdBlock Plus

1)Click on the icon in the browser’s toolbar.
2)Click on the toggle to disable it for "mrexcel.com".
Go back

Disable uBlock Origin

Follow these easy steps to disable uBlock Origin

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back

Disable uBlock

Follow these easy steps to disable uBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back
Back
Top