Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 1
Default Excel.ActiveWindow Is Excel.ActiveWindow Returns False

Hi All,

If need to be able to compare Excel Window objects the same as you can in MS
Word (or any other app)

If you do

Excel.ActiveWindow Is Excel.ActiveWindow

in Vba it always returns false, which is clearly incorrect.

It appears that Excel is returning a different object for every returned
Window, thus not allowing Window objects to be compared as they should. Does
any only know how to get a fix on the 'true' Window Object so Windows can be
compared.

Regards
Neal



  #2   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 5,600
Default Excel.ActiveWindow Is Excel.ActiveWindow Returns False

Hi Neal,

You can grab a reference to a window and hold it, but you can't grab the
same thing again -

Set w1 = ActiveWindow
Set w2 = ActiveWindow

Set a = w1
Set b = w2

MsgBox a Is w1, , b Is w2 ' true true
MsgBox w1 Is w2, , a Is b ' false false

similar with any other window, eg Activeworkbook.windows(1)

The ActiveWindow is always ActiveWorkbook.Windows(1), assuming an
activeworkbook exists, yet some of the respective properties are different.

I could cite other anomalies

The application level windows is really a collection of all the Workbook's
windows, which in turn are the third level down from the true sole
application window.

You could store and compare window captions, though in the case of 'new'
windows the last part of the text is transitory and captions can be changed.

However, depending on your needs I suspect you might be better off storing
the a reference to the activeworkbook for later comparison.

Regards,
Peter T


"Neal Andrews" <neal@_NOSPAM_ wrote in message
...
Hi All,

If need to be able to compare Excel Window objects the same as you can in

MS
Word (or any other app)

If you do

Excel.ActiveWindow Is Excel.ActiveWindow

in Vba it always returns false, which is clearly incorrect.

It appears that Excel is returning a different object for every returned
Window, thus not allowing Window objects to be compared as they should.

Does
any only know how to get a fix on the 'true' Window Object so Windows can

be
compared.

Regards
Neal






Reply
Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules

Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On


Similar Threads
Thread Thread Starter Forum Replies Last Post
ActiveWindow.Visible = True Paulo Alexandre ( PT ) Excel Programming 5 September 29th 06 12:02 PM
How can I refer to the ActiveWindow CarolineHedges[_10_] Excel Programming 3 July 6th 06 01:14 PM
ActiveWindow VBA problem Tomasz Klim[_2_] Excel Programming 2 June 11th 06 11:04 PM
ActiveWindow.SelectedSheets.PrintPreview HelpMe Excel Programming 0 November 17th 04 03:53 PM
Using ActiveWindow.PointsToScreenPixelsY Pancho Excel Programming 5 February 7th 04 11:23 PM


All times are GMT +1. The time now is 09:46 PM.

Powered by vBulletin® Copyright ©2000 - 2025, Jelsoft Enterprises Ltd.
Copyright ©2004-2025 ExcelBanter.
The comments are property of their posters.
 

About Us

"It's about Microsoft Excel"