Reputation: 367
I have some questions about the activeworkbook/activesheet properties, would appreciate your help:
In any instances, there would be at maximum only one activeworkbook or no, and that applies to activesheet. Is that right?
If properties like ranges,cells,... are not fully qualified when used, they are by default meant to be that of the activeworkbook.activesheet. Is that right?
Will the activeworkbook change to another workbook by vba actions other than activating the other workbook?
When I use wb.ws.range(cells(x1,y1),cells(x2,y2)), are the cells implied to be the cells of wb.ws? Or do they need to be qualified?
Is it possible to run the vba codes stored in the modules of a workbook without activating the workbook?
Thank you.
Upvotes: 2
Views: 310
Reputation: 149335
In any instances, there would be at maximum only one activeworkbook or no, and that applies to activesheet. Is that right?
Yes. .ActiveWorkbook
returns a Workbook
object that represents the workbook in the active window (the window on top).
If properties like ranges,cells,... are not fully qualified when used, they are by default meant to be that of the activeworkbook.activesheet. Is that right?
Yes
Debug.Print rng.Parent.Name '<~~ This will give you the name
Will the activeworkbook change to another workbook by vba actions other than activating the other workbook?
Yes it is possible. For example if you send your Active Workbook to Back
or minimise it then if the next window in zOrder is a workbook then that will get activated
When I use wb.ws.range(cells(x1,y1),cells(x2,y2)), are the cells implied to be the cells of wb.ws? Or do they need to be qualified?
Only if ws is active then yes else they will refer to Activesheet
and hence it is always good to fully qualify your objects
With ws
Set Rng = .Range(.Cells(x1, y1), .Cells(x2, y2))
End With
Is it possible to run the vba codes stored in the modules of a workbook without activating the workbook?
Yes. You can use Application.Run
Upvotes: 1