Pass Workbook Name Into Another Workbook As A Variable

M

Minitman

Greetings,

I open one workbook which opens another workbook using the workbook
open event of the first workbook. The first workbook is the active
workbook. The first workbook's name is not always the same but it's
code is.

Is there a way that the name of the first workbook or a variable with
that name assigned to it, be used in the second workbook's code?

I tried ThisWorkbook but could not get it to work.

Any help would be greatly appreciated.

-Minitman
 
J

John_John

Hi!

"ThisWorkbook" property refers to the workbook who contains the code.

Use the "ActiveWorkbook" property.

John


Ο χÏήστης "Minitman" έγγÏαψε:
 
J

JLGWhiz

Hi J_J, I am not so sure the OP can use ActiveWorkbook to refer back to the
opening workbook. If the code is running in wb 2 then wb 2 is the active
workbook.
A crude but effective way is to store the wb 1 name in a cell of a specific
sheet and then call that cell from wb 2 macro.
 
M

Minitman

Hey John,

Thanks for the reply.

Good call. That seems to do the job if I make the first workbook
active before I start the code

Thanks.

-Minitman
(My company is called Minit Maids of Austin which makes me the
Minitman) :^>
 

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

Top