Home |
Search |
Today's Posts |
|
#1
![]()
Posted to microsoft.public.excel.programming
|
|||
|
|||
![]()
When no workbooks are open, most toolbuttons and menu options in Excel are
disabled. I have a menu and toolbar created by an add-in I built. How can I detect in my addin that no workbooks are open so I can set the toolbuttons and menu options to disabled? |
#2
![]()
Posted to microsoft.public.excel.programming
|
|||
|
|||
![]()
simon
if workbooks.count = 0 then 'disable buttons end if -- When you lose your mind, you free your life. "Simon Shaw" wrote: When no workbooks are open, most toolbuttons and menu options in Excel are disabled. I have a menu and toolbar created by an add-in I built. How can I detect in my addin that no workbooks are open so I can set the toolbuttons and menu options to disabled? |
#3
![]()
Posted to microsoft.public.excel.programming
|
|||
|
|||
![]()
where do I put the code? in ThisWorkbook?
How do I get it to execute? what event occurs when all workbooks are closed? thanks Simon "ben" wrote: simon if workbooks.count = 0 then 'disable buttons end if -- When you lose your mind, you free your life. "Simon Shaw" wrote: When no workbooks are open, most toolbuttons and menu options in Excel are disabled. I have a menu and toolbar created by an add-in I built. How can I detect in my addin that no workbooks are open so I can set the toolbuttons and menu options to disabled? |
#4
![]()
Posted to microsoft.public.excel.programming
|
|||
|
|||
![]()
um depends where you have the menu being created, but because that workbook
may be closed before all others the code would do you no good. reccomend putting it in an add-in and the in the workbook close event on the application level http://www.cpearson.com/excel/AppEvent.htm -- When you lose your mind, you free your life. "Simon Shaw" wrote: where do I put the code? in ThisWorkbook? How do I get it to execute? what event occurs when all workbooks are closed? thanks Simon "ben" wrote: simon if workbooks.count = 0 then 'disable buttons end if -- When you lose your mind, you free your life. "Simon Shaw" wrote: When no workbooks are open, most toolbuttons and menu options in Excel are disabled. I have a menu and toolbar created by an add-in I built. How can I detect in my addin that no workbooks are open so I can set the toolbuttons and menu options to disabled? |
#5
![]()
Posted to microsoft.public.excel.programming
|
|||
|
|||
![]()
Note: that this also count the personal.xls workbook that is 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 "ben" (remove this if mailing direct) wrote in message ... simon if workbooks.count = 0 then 'disable buttons end if -- When you lose your mind, you free your life. "Simon Shaw" wrote: When no workbooks are open, most toolbuttons and menu options in Excel are disabled. I have a menu and toolbar created by an add-in I built. How can I detect in my addin that no workbooks are open so I can set the toolbuttons and menu options to disabled? |
#6
![]()
Posted to microsoft.public.excel.programming
|
|||
|
|||
![]()
thanks,
How do I get it to execute when a different workbook is closed? "Ron de Bruin" wrote: Note: that this also count the personal.xls workbook that is 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 "ben" (remove this if mailing direct) wrote in message ... simon if workbooks.count = 0 then 'disable buttons end if -- When you lose your mind, you free your life. "Simon Shaw" wrote: When no workbooks are open, most toolbuttons and menu options in Excel are disabled. I have a menu and toolbar created by an add-in I built. How can I detect in my addin that no workbooks are open so I can set the toolbuttons and menu options to disabled? |
#7
![]()
Posted to microsoft.public.excel.programming
|
|||
|
|||
![]()
Hi Simon
You can test the count when you try to open the userform of the add-in But you can also try to set the activesheet and trap the error Sub OpenUserform() Dim asheet As Worksheet Set asheet = Nothing On Error Resume Next Set asheet = ActiveSheet On Error GoTo 0 If asheet Is Nothing Then MsgBox "Error: There is no active worksheet.", _ vbOKOnly, "Hi there" Exit Sub Else userform1.Show End If End Sub -- Regards Ron de Bruin http://www.rondebruin.nl "Simon Shaw" <simonATsimonstoolsDOTcom wrote in message ... thanks, How do I get it to execute when a different workbook is closed? "Ron de Bruin" wrote: Note: that this also count the personal.xls workbook that is 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 "ben" (remove this if mailing direct) wrote in message ... simon if workbooks.count = 0 then 'disable buttons end if -- When you lose your mind, you free your life. "Simon Shaw" wrote: When no workbooks are open, most toolbuttons and menu options in Excel are disabled. I have a menu and toolbar created by an add-in I built. How can I detect in my addin that no workbooks are open so I can set the toolbuttons and menu options to disabled? |
Reply |
Thread Tools | Search this Thread |
Display Modes | |
|
|
![]() |
||||
Thread | Forum | |||
When I open Excel, workbooks open automatically. How can I stop t | Excel Discussion (Misc queries) | |||
Excel 2003 Workbooks.Open with CorruptLoad=xlRepairFile fails on Excel 5.0/95 file due to Chart, with Error 1004 Method 'Open' of object 'Workbooks' failed | Excel Programming | |||
Workbooks.Open doesn't open file in ThisWorkbook | Excel Programming | |||
Workbooks.Open closes other workbooks | Excel Programming | |||
Workbooks.Open / .Open Text - How do you stop the .xls addition? | Excel Programming |