How can I tell if multiple sheets have been selected?
Thanks in advance
Mike
How can I tell if multiple sheets have been selected?
Thanks in advance
Mike
if activewindow.SelectedSheets.Count > 1
"Mike Weaver" wrote:
> How can I tell if multiple sheets have been selected?
>
> Thanks in advance
>
> Mike
>
>
>
Hello Mike,
It is a good practice to preface Window operations with the application to which they belong. Functions like ActiveWindow are envrironmentally dependent. If you were troubleshooting your code in the VBA Editor, ActiveWindow would assume you are referring to the active window in the VBA Editor and not Excel. To prevent these problems qualify your object methods like this...
Excel.ActiveWindow.SelectedSheets.Count
Sincerely,
Leith Ross
I stepped through this code in the VBE in book2.xls with book1.xls active in
excel:
Option Explicit
Sub testme01()
Debug.Print ActiveWindow.Caption
End Sub
I saw this in the immediate window:
book1.xls
Leith Ross wrote:
>
> Hello Mike,
>
> It is a good practice to preface Window operations with the application
> to which they belong. Functions like ActiveWindow are envrironmentally
> dependent. If you were troubleshooting your code in the VBA Editor,
> ActiveWindow would assume you are referring to the active window in the
> VBA Editor and not Excel. To prevent these problems qualify your object
> methods like this...
>
> Excel.ActiveWindow.SelectedSheets.Count
>
> Sincerely,
> Leith Ross
>
> --
> Leith Ross
> ------------------------------------------------------------------------
> Leith Ross's Profile: http://www.excelforum.com/member.php...o&userid=18465
> View this thread: http://www.excelforum.com/showthread...hreadid=509245
--
Dave Peterson
Thanks. That gets me headed in the right direction.
Mike
"Leith Ross" <Leith.Ross.22umta_1139298600.9991@excelforum-nospam.com> wrote
in message news:Leith.Ross.22umta_1139298600.9991@excelforum-nospam.com...
>
> Hello Mike,
>
> It is a good practice to preface Window operations with the application
> to which they belong. Functions like ActiveWindow are envrironmentally
> dependent. If you were troubleshooting your code in the VBA Editor,
> ActiveWindow would assume you are referring to the active window in the
> VBA Editor and not Excel. To prevent these problems qualify your object
> methods like this...
>
> Excel.ActiveWindow.SelectedSheets.Count
>
> Sincerely,
> Leith Ross
>
>
> --
> Leith Ross
> ------------------------------------------------------------------------
> Leith Ross's Profile:
> http://www.excelforum.com/member.php...o&userid=18465
> View this thread: http://www.excelforum.com/showthread...hreadid=509245
>
There are currently 1 users browsing this thread. (0 members and 1 guests)
Bookmarks