ExcelBanter

ExcelBanter (https://www.excelbanter.com/)
-   Excel Programming (https://www.excelbanter.com/excel-programming/)
-   -   Check Excel's state to see if a workbook is loaded in App (https://www.excelbanter.com/excel-programming/323991-check-excels-state-see-if-workbook-loaded-app.html)

Chris W.

Check Excel's state to see if a workbook is loaded in App
 
Does anyone know if there is a way to check Excel App. to
see if there is actually a workbook open. I'm refferring
to the conditon where Excel is open but there is no
workbook open (loaded), I would like to cancel code from
running if the App. has no loaded workbook

Fredrik Wahlgren

Check Excel's state to see if a workbook is loaded in App
 

"Chris w." wrote in message
...
Does anyone know if there is a way to check Excel App. to
see if there is actually a workbook open. I'm refferring
to the conditon where Excel is open but there is no
workbook open (loaded), I would like to cancel code from
running if the App. has no loaded workbook


I guess you could use the ActiveWorkbook property:
http://msdn.microsoft.com/library/de...bjWorkbook.asp

/Fredrik




Dave Peterson[_5_]

Check Excel's state to see if a workbook is loaded in App
 
How about:

If ActiveWorkbook Is Nothing Then
MsgBox "no active workbook"
Exit Sub
End If

At the top of your procedure.

"Chris w." wrote:

Does anyone know if there is a way to check Excel App. to
see if there is actually a workbook open. I'm refferring
to the conditon where Excel is open but there is no
workbook open (loaded), I would like to cancel code from
running if the App. has no loaded workbook


--

Dave Peterson

Walt Weber[_2_]

Check Excel's state to see if a workbook is loaded in App
 
Hi Chris,

It's not clear how you've opened or are controlling this
instance of Excel, but the following may help (It works as
a sheet event within a workbook in Excel):

Private Sub Worksheet_SelectionChange(ByVal Target As
Range)
MsgBox Application.Workbooks.Count
End Sub

App.Workbooks.Count may get you there.

Best Regards,
Walt

-----Original Message-----
Does anyone know if there is a way to check Excel App. to
see if there is actually a workbook open. I'm refferring
to the conditon where Excel is open but there is no
workbook open (loaded), I would like to cancel code from
running if the App. has no loaded workbook
.



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

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