Declaring a constant to the Workbook Name?

  • Thread starter Thread starter NooK
  • Start date Start date
N

NooK

I am trying to declare a constant which will hold the workbook name (Th
workbook running the macro that is).

So I am doing

Public Const WorkBookName As String = ThisWorkbook.name

First thing in Module 1 but I keep getting:

"Constant Expression Required"

How can I declare the constant with the workbooks name?

Best Regards

Noo
 
You already have a constant you can access

Thisworkbook.Name

Why reinvent the wheel?

If you want to store the name because you are going to change it, then just
use a variable (rather than a constant).
 
I am not gonna change just tought it'd look nicer to have a variabl
instead of writing Thisworkbook.name all the time.

Anyway, thanks for the answer.

I think this might be the best solution in this case.

Best Regards

Noo
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Back
Top