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

Highlight Duplicates
Home, Conditional Formatting, Highlight Cells, Duplicate records, OK to add pink formatting to any duplicates in selected range.

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:
 

Watch MrExcel Video

Forum statistics

Threads
1,130,342
Messages
5,641,592
Members
417,224
Latest member
llama9207

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