+ Reply to Thread
Results 1 to 4 of 4

Checking for workbooks

  1. #1
    Forum Contributor
    Join Date
    12-04-2003
    Location
    Burrton, Kansas USA
    MS-Off Ver
    2003
    Posts
    162

    Checking for workbooks

    Hi!
    I would like to write code that checks to see how many workbooks (windows) are open on this application. Can someone help me?
    I have code that goes to the next active window and copies a specified range. If there is no other workbook open or if there is more than 1 other workbook open then I want to display a message box that instructs the user and stops the macro.
    Thanks for your time!

  2. #2
    Norman Jones
    Guest

    Re: Checking for workbooks

    Hi Brian,

    Try:

    If Not Workbooks.Count = 2 Then
    'your warning
    Exit Sub
    End if


    ---
    Regards,
    Norman


    "Brian Matlack" <[email protected]>
    wrote in message
    news:[email protected]...
    >
    > Hi!
    > I would like to write code that checks to see how many workbooks
    > (windows) are open on this application. Can someone help me?
    > I have code that goes to the next active window and copies a specified
    > range. If there is no other workbook open or if there is more than 1
    > other workbook open then I want to display a message box that instructs
    > the user and stops the macro.
    > Thanks for your time!
    >
    >
    > --
    > Brian Matlack
    > ------------------------------------------------------------------------
    > Brian Matlack's Profile:
    > http://www.excelforum.com/member.php...fo&userid=3508
    > View this thread: http://www.excelforum.com/showthread...hreadid=510541
    >




  3. #3
    Ron de Bruin
    Guest

    Re: Checking for workbooks

    Hi Brian

    Note:

    Workbooks.Count
    This count also hidden workbooks(personal.xls)

    --
    Regards Ron de Bruin
    http://www.rondebruin.nl


    "Norman Jones" <[email protected]> wrote in message news:[email protected]...
    > Hi Brian,
    >
    > Try:
    >
    > If Not Workbooks.Count = 2 Then
    > 'your warning
    > Exit Sub
    > End if
    >
    >
    > ---
    > Regards,
    > Norman
    >
    >
    > "Brian Matlack" <[email protected]> wrote in message
    > news:[email protected]...
    >>
    >> Hi!
    >> I would like to write code that checks to see how many workbooks
    >> (windows) are open on this application. Can someone help me?
    >> I have code that goes to the next active window and copies a specified
    >> range. If there is no other workbook open or if there is more than 1
    >> other workbook open then I want to display a message box that instructs
    >> the user and stops the macro.
    >> Thanks for your time!
    >>
    >>
    >> --
    >> Brian Matlack
    >> ------------------------------------------------------------------------
    >> Brian Matlack's Profile: http://www.excelforum.com/member.php...fo&userid=3508
    >> View this thread: http://www.excelforum.com/showthread...hreadid=510541
    >>

    >
    >




  4. #4
    Forum Contributor
    Join Date
    12-04-2003
    Location
    Burrton, Kansas USA
    MS-Off Ver
    2003
    Posts
    162
    Quote Originally Posted by Ron de Bruin
    Hi Brian

    Note:

    Workbooks.Count
    This count also hidden workbooks(personal.xls)

    --
    Regards Ron de Bruin
    http://www.rondebruin.nl


    "Norman Jones" <[email protected]> wrote in message news:[email protected]...
    > Hi Brian,
    >
    > Try:
    >
    > If Not Workbooks.Count = 2 Then
    > 'your warning
    > Exit Sub
    > End if
    >
    >
    > ---
    > Regards,
    > Norman
    >
    >
    > "Brian Matlack" <[email protected]> wrote in message
    > news:[email protected]...
    >>
    >> Hi!
    >> I would like to write code that checks to see how many workbooks
    >> (windows) are open on this application. Can someone help me?
    >> I have code that goes to the next active window and copies a specified
    >> range. If there is no other workbook open or if there is more than 1
    >> other workbook open then I want to display a message box that instructs
    >> the user and stops the macro.
    >> Thanks for your time!
    >>
    >>
    >> --
    >> Brian Matlack
    >> ------------------------------------------------------------------------
    >> Brian Matlack's Profile: http://www.excelforum.com/member.php...fo&userid=3508
    >> View this thread: http://www.excelforum.com/showthread...hreadid=510541
    >>

    >
    >
    Works Great!! Thanks!!

+ Reply to Thread

Thread Information

Users Browsing this Thread

There are currently 1 users browsing this thread. (0 members and 1 guests)

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts

Search Engine Friendly URLs by vBSEO 3.6.0 RC 1