Find name of external open workbook using VBA

9tanstaafl9

Well-known Member
Joined
Mar 23, 2008
Messages
535
I need to copy data from an open workbook for which I do not know the name, into my workbook that contains the macro that finds this information. I need to know how to get the name of the workbook with the data. Is this possible? I've searched the Internet for two days now and can't find it. I'm afraid it is just such an easy question that no one has felt the need to post it. If it is simply impossible, I would like to know that too.


I could, for example, ask the user to click somewhere on the target workbook if that would help.I tried doing something similar, but only managed to get the so address where the user clicks. Not the workbook name or path.
I can't just use index numbers, because it is possible the user might have other workbooks open, and also I don't know what order they would open them in. Also I cannot edit or make changes to the unknown workbook..


Any help or ideas would be appreciated
 
NEVERMIND. I figured it out. Feeling pretty clever right now...

I used this:

Code:
If wb Is Nothing Then 'do stuff
 
Upvote 0
NEVERMIND. I figured it out. Feeling pretty clever right now...

I used this:

Code:
If wb Is Nothing Then 'do stuff

Well done you :-)

That's pretty much the same as what I would have suggested anyway, I just tend to go at it from the opposite side.

Code:
If Not wb Is Nothing Then Exit Sub
 
Upvote 0

Forum statistics

Threads
1,226,795
Messages
6,193,047
Members
453,772
Latest member
aastupin

We've detected that you are using an adblocker.

We have a great community of people providing Excel help here, but the hosting costs are enormous. You can help keep this site running by allowing ads on MrExcel.com.
Allow Ads at MrExcel

Which adblocker are you using?

Disable AdBlock

Follow these easy steps to disable AdBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the icon in the browser’s toolbar.
2)Click on the "Pause on this site" option.
Go back

Disable AdBlock Plus

Follow these easy steps to disable AdBlock Plus

1)Click on the icon in the browser’s toolbar.
2)Click on the toggle to disable it for "mrexcel.com".
Go back

Disable uBlock Origin

Follow these easy steps to disable uBlock Origin

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back

Disable uBlock

Follow these easy steps to disable uBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back
Back
Top