Close the VBE Environment

AgentSmith

Well-known Member
Joined
Mar 8, 2004
Messages
575
I have a simple macro that launches WordPad and opens a text file via the command line. Unfortunately WordPad isn't an automation server, so the only way I can think of doing formatting is via the (admittedly horrible) SendKeys command.

My problem is that if I run this macro directly from the VBE environment then the keystrokes are actually done in the VBE window rather than in WordPad. Does Excel give me a way to automatically close the VBE environment completely? I did try this:
Code:
Application.VBE.MainWindow.Close
but got some really unhelpful error message.

If not then a second best would be to figure out the the VBE environment is open and active. If so then I would bypass the SendKeys bit.

Perhaps there is a way using API calls?

Hope this makes sense. TIA.
 

Excel Facts

Bring active cell back into view
Start at A1 and select to A9999 while writing a formula, you can't see A1 anymore. Press Ctrl+Backspace to bring active cell into view.

AgentSmith

Well-known Member
Joined
Mar 8, 2004
Messages
575
I should add that I have tried using Word, but it seems to take much longer to open the document in question. Plus it seems like overkill for a simple text file.

However, it is an automation server ... :confused:
 
Master Excel Bundle

Excel contains over 450 functions, with more added every year. That’s a huge number, so where should you start? Right here with this bundle.

Forum statistics

Threads
1,164,074
Messages
5,835,229
Members
430,349
Latest member
Gregori

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
Top