VBA Code

The difference between "ThisWorkbook" and "ActiveWorkbook" refers to the workbook that is currently in the active window, whereas "ThisWorkbooK" refers to the workbook where the code is actually running from.


loop through all the worksheets
loop through all the workbooks in a folder



Activating and Selecting

Workbooks("Wbk1.xls").Activate 

Can be used if the workbook is new and has not yet been saved.

Workbooks("Book3").Activate 
Workbooks("Book3.xls").Activate

assuming that the workbook has been saved

Workbooks.Item(2).Activate 

This refers to the workbook that contains the code.

ThisWorkbook. 


ThisWorkbook

This is always the workbook that contain the code.

Application.ThisWoorkbook 
ThisWorkbook


ActiveWorkbook

This is the worksheet that is currently active or selected

Application.ActiveWorkbook 
ActiveWorkbook
ActiveWorkbook.Path = "C:\Temp"
ActiveWorkbook.Name = "Book2"


Application.Height 
Application.Left
Application.Top
Application.Width

Application.UsuableWidth 
Application.UsuableHeight



Application.ProductCode 
Application.Hwnd
Application.MemoryUsed
Application.UsedObjects

objWorkbook.CreateBackup = False 


FullName

There is only a folder path when the workbook has been saved
This property is equivalent to the Path property, followed by the current file system separator, followed by the Name property.

ActiveWorkbook.FullName 


Determines the version of a workbook, i.e. which version of Excel created this workbook.

ActiveWorkbook.FileFormat 

16 = Excel 2
29 = Excel 3
33 = Excel 5
39 = Excel 5/96
-4143 = Excel 97/2000/2002/2003



undo the last action performed by the user interface.

Application.Undo 
Application.Repeat


Returns the collection of recently opened files

Application.RecentFiles 

Read-only returns an object allowing manipulation of the office assistant.

Application.Assistant 

Some of the content in this topic may not be applicable to some languages.


AnswerWizard

There's only one Answer Wizard per application, and all changes to the AnswerWizard or the AnswerWizardFiles collection affect the active Office application immediately.

Application.AnswerWizard 
Application.AnswerWizard.ResetFileList


© 2024 Better Solutions Limited. All Rights Reserved. © 2024 Better Solutions Limited TopPrevNext