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?
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?