Eventhandler VBE

BartH

New Member
Joined
Jul 4, 2006
Messages
14
Hello,

In this post (http://www.mrexcel.com/forum/showthread.php?t=39411) Tom Schreiner shows us a variation on Chip Pearson's VBE explanation, to run a procedure with a custom made command in the VBE menu or toolbar.

I am experimenting with this and run into the following problem:

I want to add a string to the current module. This is no problem as long as I fire the procedure from within itself (hit F5). When I address the procedure to a VBE Command item, I am able to only run it once. Also other Custom Commands become inactive, so I suspect the VBIDE.CommandBarEvents is stopped by something. When I change the code to display the string as debug.print, I can run the procedure from the custom made command without any problem.

My testcode is:

Sub Test()
' Inserts string to first line of module (but only once when fired from custom command)
Application.VBE.ActiveCodePane.CodeModule.InsertLines 1, "' Time: " & Time
End Sub

Change that to

Sub Test()
Debug.Print "'Time: " & Time
End Sub

and I can run it endlessly.

Any ideas?
 

Excel Facts

Back into an answer in Excel
Use Data, What-If Analysis, Goal Seek to find the correct input cell value to reach a desired result

Forum statistics

Threads
1,214,979
Messages
6,122,552
Members
449,088
Latest member
davidcom

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