Is there any way to have a macro, that is started from the immediate window, close the immediate window when it's done. My macro closes the immediate window, but as soon as it ends, the immediate window reopens and my cursor is inside it.
Is there any way to have a macro, that is started from the immediate window, close the immediate window when it's done. My macro closes the immediate window, but as soon as it ends, the immediate window reopens and my cursor is inside it.
Last edited by foxguy; 04-20-2009 at 02:29 PM. Reason: solved in another thread
You can't close or clear the Immediate window from VBA.
Why are you invoking macros from there?
Entia non sunt multiplicanda sine necessitate
I have added VBE menus that call utilitie macros in a dedicated project (VBE.xls). But some of those utilities clear the VBE menus when they are run on a VBE.xls codepane. I then have to re-run the macro that sets up my VBE menus. That can't be done from within the utilitie. It has to be run AFTER the utilitie has ended. By using SendKeys in the Immediate window, I can re-run Menu_Setup, but it leaves the Immediate window open and in my way. I'm trying to find a way to run Menu_Setup and close the immediate window.
There may be a method using Windows API, but I think none without (other than SendKeys to clear the window).
Last edited by shg; 04-18-2009 at 10:50 PM.
Will this work for you?
![]()
Please Login or Register to view this content.
Andy, the problem is that I need to call "CloseImmediateWindow()" from within the immediate window. As soon as it's finished the Immediate Window reopens.
hi Foxguy,
I don't know much about using code to work on the VBE but I have a few thoughts...
-Rather than the approaches suggested in the posts, would it be easier for your utility to test which code pane is active & not to clear the menus if it is working on a VBE.xls codepane?
-Can you start Menu_Setup directly via:
- [alt + F8] from Excel
- pressing [F5] to run the macro from a code pane & having the code flick to the next VBE window before starting (similar to "ActiveWindow.ActivateNext")
- a "hidden" (.visible = false) or discreet button on the utility UI (or a toolbar) to rerun Menu_Setup?
hth
Rob
Rob Brockett
Kiwi in the UK
Always learning & the best way to learn is to experience...
Rob,
I have no control over whether the VBE menus are cleared. They aren't like the menus in Excel. When a codepane, in the project that has Menu_Setup in it, is modified in certain ways, it clears the VBE menus.
I have no problem manually rerunning Menu_Setup, it's just one click somewhere (either in a copepane, or the immediate window). I'm trying to get it to do it automatically. It's just irritating to have to manually close the immediate window when I'm updating my utilities.
Createing a button to rerun Menu_Setup is pointless, because when the menus get cleared ALL the buttons get cleared including the one that would rerun Menu_setup.
oh well, it was worth asking but it is well beyond my knowledge - fingers crossed that Andy, Shg or others have more tricks up their sleeves...
Rob
foxguy
Why are you altering the menus in the VBE in the first place?
I can't think of any reason you might want/need to do that.
Am I missing something?
PS You do realise that programming code with code can have some security issues.
Norie,
One of the things I do:
ALL my macros have the same format
I got tired of typing all that everytime I created a new function. So I created a macro that inserts that code into the active codepane, and created a button in the VBE menus to trigger it.![]()
Please Login or Register to view this content.
Now all I do is put my cursor where I want a new function, right mouse click, and select "New Function", then change the function name to what I want. It even selects the function name, so I don't even have to select it, I just start typing. Works great.
But if I insert a new function into the project that contains Menu_Setup, it clears my VBE menus.
I have several utilities (each with it's own button) to do things. I can comment out an entire section of code, Un-comment it back out, insert common statments like "On Error Resume Next", resize codepanes and more. They don't all clear my VBE menus, but the ones that do are irritating.
Why are you using Function?
PS I've got a utility that allows me to comment/uncomment blocks of code - it's on the VBE Edit toolbar, think it's built in.
There also another feature in the VBE - Import/Export...module.![]()
Norie,
I'm at a loss as to your points.
I use function when I need a function, I use sub when I need a sub. I don't understand the question.
I don't argue that I can't do these things without writing modifying code and changing my VBE menus. I'm just saying that it's more convenient to do it my way. That may not be true for you.
I never noticed that there was an Edit toolbar in VBE. The Edit>Indent/Outdent work better than my Edit/Outdent, so I'll have my button call them instead of my Indent/Outdent macros. Thanks
hi Foxguy,
I'll try to make this the last post from me because you may have had enough of me by now...?
This is getting off topic but ties in with the last few posts - I find the below very useful in my coding development & hopefully they'll help you out too:
Stephen Bullen's Smart Indenter (I think it is much better than the native VBE version!):
http://www.oaltd.co.uk/Indenter/Default.htm
from the VBA Programming section 2/3rds of the way down this sheet: http://www.oaltd.co.uk/Excel/Default.htm
Rob Bovey's Code Cleaner & Documentor:
http://www.appspro.com/Utilities/CodeCleaner.htm
http://www.appspro.com/Utilities/Documentor.htm
+ others available at: http://appspro.com/Utilities/Utilities.htm
Carlos J. Quintero's mztools (3.0):
http://www.mztools.com/index.aspx
Hth
Rob
Last edited by broro183; 04-19-2009 at 06:06 PM. Reason: deleted duplicate link
Rob, thanks for the links. I have generally liked developing these tools myself, but I'm always interested in how other people are doing things.
Good as gold, it is the best way to learn - thanks for the feedback![]()
To stop the IM reopening try calling DelayedClose from the immediate window,
![]()
Please Login or Register to view this content.
Nicely done, Andy.
Andy, clever.
It works, but now I have another problem, that I thought was solved. But that's another thread.
There are currently 1 users browsing this thread. (0 members and 1 guests)
Bookmarks