Home | Contact Us | FAQ | Search & Site Map | Link to Us
Sign In | Join | Other 45 Sites in Network
Home
DiscussionsAccessExcelInfoPathOutlookPowerPointPublisherWord
DirectoryUser Groups
Related Topics
Outlook ExpressInternet ExplorerWindowsMS Server ProductsMore Topics ...

MS Office Forum / Excel / Programming / March 2006

Tip: Looking for answers? Try searching our database.

If no workbooks are open?

Thread view: 
Enable EMail Alerts  Start New Thread
Thread rating: 
jayklmno - 21 Mar 2006 19:43 GMT
I am working with an addin and if triggered from the menu, with no workbooks
open, how can I check to see if there are any workbooks open and if not,
prompt for one?

Thanks,
Jay
Tom Ogilvy - 21 Mar 2006 20:07 GMT
Sub ccc()
Dim bk As Workbook
Dim w As Window
If Workbooks.Count = 0 Then
 'none open
  MsgBox "Open a workbook"
  Exit Sub
Else
 ' check for any visible
 bVisible = False
 For Each bk In Workbooks
   For Each w In bk.Windows
      Debug.Print w.Caption, w.Visible
      If w.Visible = True Then
       
        bVisible = True
      End If
    Next
 Next
End If
if bVisible = false then
 msgbox "Open a workbook"
 exit sub
End if
' more code
End Sub

Signature

Regards,
Tom Ogilvy

> I am working with an addin and if triggered from the menu, with no workbooks
> open, how can I check to see if there are any workbooks open and if not,
> prompt for one?
>
> Thanks,
> Jay
jayklmno - 21 Mar 2006 20:33 GMT
Thanks! I thought it would involve the workbooks.count, but when I tried it,
even thought no workbooks were visible, it had 1 for a count. But, that's
what your visible check is for... Thanks again!

> Sub ccc()
> Dim bk As Workbook
[quoted text clipped - 29 lines]
> > Thanks,
> > Jay
 
Sign In
Join
My Latest Posts
My Monitored Threads
My Blog
My Photo Gallery
My Profile
My Homepage

Start New Thread
Enable EMail Alerts
Rate this Thread



©2008 Advenet LLC   Privacy Policy - Terms of Use
This website includes both content owned or controlled by Advenet as well as content owned or controlled by third parties.