Workbooks.count not counting



After I convert my workbook to EXE the VBA “workbooks.count” methud always return 1.

Do you have a solution ?

Thank you !


The secure application should only contain the compiled workbook. Do you open another workbook with VBA?


Yes, I want to open another (regular) workbook with VBA, but before I open this workbook I want to check that my secure application file is the only file that is open, and if my end user have other Excel file or files (regular excel file) that is open I must inform him to close all excel files.

I use the “workbooks.count” method so my VBA code to check if my end user have another excel file open is something like this:

if workbooks.count >1 then
      msgbox "Please close all Excel files that are open, except this file"
      exit sub
end if

This logic is working great on my VBA code but when I use it in the EXE file ,the workbooks.count method returns always 1, so its not working.


workbooks.count will only work for the secure instance, and not other Excel instances. So it’s normal that you always get 1.


ok, so I can I inform my end user if he have another workbook open ?


I found a solution, thank you.