VBA code to check if another window is open?

  • Thread starter Thread starter Guest
  • Start date Start date
G

Guest

I need to check if another window is open - if not I am going to display a
dialog box letting them know to open the file (or possibly opening a browse
window for them to open it), and if so, just keep going
 
Just to confrim you want to know if another file is open? If it is not open
then why not just open it yourself, something like this...

dim wbk as workbook

on error resume next
set wbk = workbooks("MyBook.xls")
on error goto 0
is wbk is nothing then _
set wbk = workbooks.open("Mybook.xls")
 
Ok, I tried modifying the code to give a msgbox saying "Open Quote System" if
the window is not found - but it says that if the window is found or not.
I guess I'm not sure of the exact wbk property - the file is a template
(Quote System.xlt), when opened the default is Quote System1 - but I set wbk
to Quote System1 and Quote System1.xls, it didn't work either time.
 
This code doesn't work either

If Windows("Quote System1").Visible = True Then MsgBox "Visible" _
Else MsgBox "Not Visible"

If the window is open, it will give a msgbox saying "Visible", but if it's
not open it gives me an error - Subscript out of range.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Back
Top