3

I'll also note, that the Application.Run("<workbook name>!<public VBA function name>") allows jumps of the execution to other workbooks without changing the ActiveWorkbook property.

I want to know the name of the workbook which hosts the currently executing VBA code.

In case if someone did understand me wrong:

  • The trivial ActiveWorkbook wouldn't do, because the active workbook might be completely different then the one, where the running VBA macro is located.
  • The Me object isn't the ticket either. It contains the reference to the class which method is currently executing, regardless of the hosting object (it would work only if my VBA code is in a method of the Worksheet or Workbook class).

1 Answer 1

6

I want to know the name of the workbook which hosts the currently executing VBA code.

Debug.Print ThisWorkbook.Name 
Sign up to request clarification or add additional context in comments.

1 Comment

Works great. Confirmed. I'm so happy I don't have to play with VBIDE classes!

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.