Previous in Forum: How to Take Virus Definition Through LAN?   Next in Forum: Plotting GPS points on a map
Close
Close
Close
2 comments
Rate Comments: Nested
Power-User

Join Date: Feb 2011
Location: Shimurali, Westbengal,India
Posts: 119

Excel VBA Program to Close All Running Excel Programs and Open the Current Excel

05/30/2013 8:32 AM

I want to open an excel file containing VBA code. I want to close all running excels and then open the current one. How it is possible using VBA code.

Register to Reply
Interested in this topic? By joining CR4 you can "subscribe" to
this discussion and receive notification when new comments are added.

"Almost" Good Answers:

Check out these comments that don't yet have enough votes to be "official" good answers and, if you agree with them, vote them!
Guru

Join Date: Oct 2008
Posts: 42355
Good Answers: 1693
#1

Re: Excel VBA Program to Close All Running Excel Programs and Open the Current Excel

05/30/2013 5:16 PM
Register to Reply
Power-User

Join Date: Oct 2008
Location: Troy, NY
Posts: 122
Good Answers: 4
#2

Re: Excel VBA Program to Close All Running Excel Programs and Open the Current Excel

05/31/2013 9:07 AM

The problem is if you close all the open Excel files, the one with your VBA code will also close. You can try doing it from Access VBA.

Here's some code to loop through your open workbooks in Excel VBA:

Sub Macro1()

Dim appExcel As Excel.Application

Dim wb As Workbook

'Set application object

Set appExcel = Application

'Loop through open excel workbooks

For Each wb In appExcel.Workbooks

'print workbook name

debug.print wb.name

Next wb

End Sub

Register to Reply Score 1 for Good Answer
Register to Reply 2 comments

"Almost" Good Answers:

Check out these comments that don't yet have enough votes to be "official" good answers and, if you agree with them, vote them!

Previous in Forum: How to Take Virus Definition Through LAN?   Next in Forum: Plotting GPS points on a map

Advertisement