ExcelBanter

ExcelBanter (https://www.excelbanter.com/)
-   Excel Programming (https://www.excelbanter.com/excel-programming/)
-   -   Is there a workbook open in Excel? (https://www.excelbanter.com/excel-programming/336262-there-workbook-open-excel.html)

ExcelMonkey

Is there a workbook open in Excel?
 
how do you tell in VBA if there is workbook open in excel. That is, when I
launch my xla, I want to check to see if there is at least one workbook open.
If not, I will prompt user to open workbook and exit the xla.

Thanks

Hayeso

Is there a workbook open in Excel?
 
If workbooks.count0 then
end if

"ExcelMonkey" wrote:

how do you tell in VBA if there is workbook open in excel. That is, when I
launch my xla, I want to check to see if there is at least one workbook open.
If not, I will prompt user to open workbook and exit the xla.

Thanks


Bob Phillips[_6_]

Is there a workbook open in Excel?
 
Be aware, this will count Personal.xls if there is one

--
HTH

Bob Phillips

"Hayeso" wrote in message
...
If workbooks.count0 then
end if

"ExcelMonkey" wrote:

how do you tell in VBA if there is workbook open in excel. That is,

when I
launch my xla, I want to check to see if there is at least one workbook

open.
If not, I will prompt user to open workbook and exit the xla.

Thanks




ExcelMonkey

Is there a workbook open in Excel?
 
If it counts personal workbooks then I likely cannot us it unless there is a
way for me to tell that it is a personal workbook. I am only interested in
regular workbooks.

EM

"Bob Phillips" wrote:

Be aware, this will count Personal.xls if there is one

--
HTH

Bob Phillips

"Hayeso" wrote in message
...
If workbooks.count0 then
end if

"ExcelMonkey" wrote:

how do you tell in VBA if there is workbook open in excel. That is,

when I
launch my xla, I want to check to see if there is at least one workbook

open.
If not, I will prompt user to open workbook and exit the xla.

Thanks





Ron de Bruin

Is there a workbook open in Excel?
 
Loop through the workbooks and check if they are hidden

Dim wb As Workbook
Dim Num As Integer
Num = 0
For Each wb In Application.Workbooks
If wb.Windows(1).Visible Then
Num = Num + 1
End If
Next
MsgBox Num


--
Regards Ron de Bruin
http://www.rondebruin.nl


"ExcelMonkey" wrote in message ...
If it counts personal workbooks then I likely cannot us it unless there is a
way for me to tell that it is a personal workbook. I am only interested in
regular workbooks.

EM

"Bob Phillips" wrote:

Be aware, this will count Personal.xls if there is one

--
HTH

Bob Phillips

"Hayeso" wrote in message
...
If workbooks.count0 then
end if

"ExcelMonkey" wrote:

how do you tell in VBA if there is workbook open in excel. That is,

when I
launch my xla, I want to check to see if there is at least one workbook

open.
If not, I will prompt user to open workbook and exit the xla.

Thanks








All times are GMT +1. The time now is 05:37 PM.

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