ExcelBanter

ExcelBanter (https://www.excelbanter.com/)
-   Excel Programming (https://www.excelbanter.com/excel-programming/)
-   -   Application close problem (https://www.excelbanter.com/excel-programming/339017-application-close-problem.html)

Tempy

Application close problem
 
Good day, i need some help with the problem of, if the user has an
instance of excel open and is busy working then uses my document with
macro's and at the end i quit the application and his also closes and he
looses all his changes !! I believe you can check if there is other
instances of excel running and if yes then close workbook else quit.
I however am not sure how to write the code, could somebody please help.

thanks in advance

Tempy

*** Sent via Developersdex http://www.developersdex.com ***

Tempy

Application close problem
 
Hi, maybe i did not explain myself properly. If the user is working with
a spreadsheet in excel and needs to run my excel document to do
something, excel needs to check how many workbooks are open and if only
1 then it will quit, however if there is more than 1 workbook open then
it must just close the workbook with my code in.

Tempy

*** Sent via Developersdex http://www.developersdex.com ***

NickHK

Application close problem
 
Tempy,
For your macro to run, hence there will be an instance of Excel.
I think what mean is "Was this instance already running before the user
opened my workbook ?"

You could evaluate Workbooks.Count, allowing for Personal and Add-Ins.

Or simply do not quit Excel.

NickHK

"Tempy" wrote in message
...
Good day, i need some help with the problem of, if the user has an
instance of excel open and is busy working then uses my document with
macro's and at the end i quit the application and his also closes and he
looses all his changes !! I believe you can check if there is other
instances of excel running and if yes then close workbook else quit.
I however am not sure how to write the code, could somebody please help.

thanks in advance

Tempy

*** Sent via Developersdex http://www.developersdex.com ***




NickHK

Application close problem
 
Tempy,
Yes, so:
"You could evaluate Workbooks.Count, allowing for Personal and Add-Ins."

Correction: "You could evaluate Workbooks.Count, allowing for Personal"

NickHK

"Tempy" wrote in message
...
Hi, maybe i did not explain myself properly. If the user is working with
a spreadsheet in excel and needs to run my excel document to do
something, excel needs to check how many workbooks are open and if only
1 then it will quit, however if there is more than 1 workbook open then
it must just close the workbook with my code in.

Tempy

*** Sent via Developersdex http://www.developersdex.com ***




Tempy

Application close problem
 
Hello NickHK, i am unfortunately not a programmer, could explain please
and help with the code ?

Thanks

Tempy

*** Sent via Developersdex http://www.developersdex.com ***

Tempy

Application close problem
 
Hi i have tried the following:
wkb = Application.Workbooks.Count

But it only returns a count of 1 no matter how many workbooks are open ?


Tempy

*** Sent via Developersdex http://www.developersdex.com ***

NickHK

Application close problem
 
Tempy,
You are opening the workbooks in the same instance of Excel ?

Look at the Task manager to see how instances of Excel are running.

NickHK

"Tempy" wrote in message
...
Hi i have tried the following:
wkb = Application.Workbooks.Count

But it only returns a count of 1 no matter how many workbooks are open ?


Tempy

*** Sent via Developersdex http://www.developersdex.com ***




Tempy

Application close problem
 
If i look at my task manager it shows me 2 instances of excel running.

1. Microsft Excel - Recon_Master.xls (my doc with code)
a. Personal.xls
b. Recon_Master.xls
2. Microsoft Excel - Book1


Tempy

*** Sent via Developersdex http://www.developersdex.com ***

NickHK

Application close problem
 
Tempy
So if you put a button on a worksheet in your Recon_Master.xls, with this
code:

Private Sub CommandButton1_Click()
MsgBox Application.Workbooks.Count
End Sub

What value do you see ?

NickHK


"Tempy" wrote in message
...
If i look at my task manager it shows me 2 instances of excel running.

1. Microsft Excel - Recon_Master.xls (my doc with code)
a. Personal.xls
b. Recon_Master.xls
2. Microsoft Excel - Book1


Tempy

*** Sent via Developersdex http://www.developersdex.com ***





All times are GMT +1. The time now is 04:58 PM.

Powered by vBulletin® Copyright ©2000 - 2025, Jelsoft Enterprises Ltd.
ExcelBanter.com