Home » excel » excel – ActiveWorkbook vs ActiveWindow

excel – ActiveWorkbook vs ActiveWindow

Posted by: admin May 14, 2020 Leave a comment

Questions:

What is the difference between ActiveWorkbook and ActiveWindow?

Sometimes I feel they are the same.

How to&Answers:
  • Windows and Workbooks do have different properties/methods (although some are the same) so you can’t always do with one what you might with the other.

  • ActiveWindowClose will not always close the workbook (for example if you have two or more windows open in the activeworkbook for example).

  • Also, if you use Windows(wbName).Activate then you are also at the mercy of your windows settings (“Hide extensions for known file types”) which will determine how your windows name appears (i.e. with or without the .xls(x) extension for example) which may cause the code to bug out.

  • Generally much better to avoid referring to the window unless you need to (e.g. to change the Height).