Workbook Reference for Macros

  • Thread starter Thread starter Rich
  • Start date Start date
R

Rich

How can I control the workbook reference when I assign a
macro to a toolbar button?

I want the workbook reference to always be the current
workbook.

TIA,
Rich
 
I'm sure the gurus can explain this in more detail, but basically ThisWorkbook
refers to the workbook the macro is stored in, and ActiveWorkbook refers to
the - yes - active workbook.

Enter the following macro in a code module:

'----
Public Sub WorkbookNames()
MsgBox "This = " & ThisWorkbook.Name & " Active = " & ActiveWorkbook.Name
End Sub
'----

HTH
Anders Silvén
 
Back
Top