Closing/ending an external program

Von Pookie

MrExcel MVP
Joined
Feb 17, 2002
Messages
13,686
I know I can start an external program by using the Shell command, but how can I *end* the program?

I'm assuming something to do with API, which I have never used. I've searched and searched, and can't seem to find any already-written code that works. You would think someone, somewhere would have asked this already but if they have, it is very well hidden. All I keep finding is code to close instances of Excel or run a program and then continue a macro after the shell program ends, neither of which are the scenario that applies here. Actually, I take that back. I found this newsgroup post which is asking the exact same thing but the code posted does not work. I've also skimmed www.allapi.net but I can't figure out how to put the code together myself.

All I'm trying to do is start VBScroll when Excel opens and end it when Excel closes.

VBScroll simply sits in the taskbar; I have to right-click the icon and select Exit from the menu to close it. Current specs would be Excel 2002, Windows 2000. I was figuring on just adding the code to Personal.xls, nothing fancy. It's easy enough to start VBScroll with the shell command, no problems there. I just can't figure out how to end it.

Any <s>delicious cookies,</s> ideas, links, what have you?
 
Tom

I've downloaded both Kristy and your's suggestions.

One thing about Kristy's link is that the site was last updated in 2002, but it seems pretty up to date to me as it has a tab for .NET.

As to your link that API Viewer actually has a menu option that opens up the API guide from the link Kristy posted.

I think I'm going to have some fun with this stuff, perhaps somebody could inform Jaafar of these resources, I think he might like them.:)
 
Upvote 0

Excel Facts

Create a chart in one keystroke
Select the data and press Alt+F1 to insert a default chart. You can change the default chart to any chart type
Tom:
Kristy.

Change:
Private Sub Workbook_Close()
To:
Private Sub Workbook_BeforeClose(Cancel As Boolean)
Gah. That was me spazzing out completely, obviously. Thanks for catching that.

It didn't fix the problem, though.

If that does not work, rename personal.xls and or place this sub within a standard module within your personal.xls workbook...

Sub Auto_Close()
Call ThisWorkbook.EndShelledProcess(ThisWorkbook.IDvbscroll)
End Sub

However, this *does* work. I put it in the standard module. I wonder why this works and the BeforeClose event doesn't? I've never used an "auto" event before. May need to look these up.
 
Upvote 0
Just guessing here and probably showing my ignorance but in personal.xls workbook_close etc. refer to personal.xls. Auto_Close would refer to the current workbook. Maybe.
 
Upvote 0

Forum statistics

Threads
1,225,477
Messages
6,185,210
Members
453,283
Latest member
Shortm88

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