• Hi All

    Please note that at the Chandoo.org Forums there is Zero Tolerance to Spam

    Post Spam and you Will Be Deleted as a User

    Hui...

  • When starting a new post, to receive a quicker and more targeted answer, Please include a sample file in the initial post.

Check: how many windows has opened for a particular workbook

AAP

Member
Hi,
If user opened more than single views of a workbook then the vba throws error because the workbook name has changed from Workbooks("Book1") to Workbooks("Book1:1") or Workbooks("Book1:2"). How do I write a code that inform user that he has opened many views for that workbook and needs to close before he/she begin to run another code.
Thanks
 
Hi,
If user opened more than single views of a workbook then the vba throws error because the workbook name has changed from Workbooks("Book1") to Workbooks("Book1:1") or Workbooks("Book1:2"). How do I write a code that inform user that he has opened many views for that workbook and needs to close before he/she begin to run another code.
Thanks
Hi,

You can use something like (see below) to count the number of open windows and then display a message or do whatever you want:
Code:
Sub windowscount()

    If Application.Windows.Count > 1 Then
        MsgBox Application.Windows.Count & " open windows!"
    End If

End Sub

Hope this helps
 
Hi,

You can use something like (see below) to count the number of open windows and then display a message or do whatever you want:
Code:
Sub windowscount()

    If Application.Windows.Count > 1 Then
        MsgBox Application.Windows.Count & " open windows!"
    End If

End Sub

Hope this helps

Hi,

This code is counting the windows which includes the other excel workbooks opened at that moment.
But your suggestion worked with a little manipulation.

Code:
    If ActiveWorkbook.Windows.Count > 1 Then
        MsgBox ActiveWorkbook.Windows.Count & " open windows!"
    End If


Thanks a lot!
 
Hi,

This code is counting the windows which includes the other excel workbooks opened at that moment.
But your suggestion worked with a little manipulation.

Code:
    If ActiveWorkbook.Windows.Count > 1 Then
        MsgBox ActiveWorkbook.Windows.Count & " open windows!"
    End If


Thanks a lot!
You are welcome ;)
 
Back
Top