How to access another workbook with VBA

nmay732

New Member
Joined
Jun 20, 2012
Messages
12
Normally I would just call Workbooks("workbookname").activate and everything works fine.

However, I am calling someone else's script which opens up a new instance of excel with the data I need. The instance of excel that my macro resides in doesn't have access to workbooks in this new instance of excel. The above code returns a "subscript not found" error.

Does anyone have a workaround for this? I can't get anything to work.

Thanks!
 

Excel Facts

Back into an answer in Excel
Use Data, What-If Analysis, Goal Seek to find the correct input cell value to reach a desired result
Why call someone else's script, as a matter of interest?
Does the other script return anything, such as a workbook or application reference? If not, if you know the path to the workbook in question, you can use GetObject to get a reference to it.
 
Upvote 0
I'm calling his script because it goes off and fetches a lot of data from a database, then parses it. It's a rather complicated script with a lot of options. It does more than what I'm asking it to do for this particular project. It would just be a really big pain to go rewrite what has already been written. And unfortunately it doesn't return any refrences. It just opens up a new spreadsheet with the data. Which isn't saved yet, so I wouldn't be able to use a path either. = /

Thanks for the quick response = )
 
Upvote 0
Do you at least know its name? If so you can use API calls to get a reference to it.
 
Upvote 0
I believe it's just Sheet1.xlsxHow would I use an API call? I haven't used those yet.
It would not have an extension if it hasn't been saved. Is it actually book1 or sheet1, or something else?
 
Upvote 0
It just says "Sheet1" at the top. I just assumed the default extension. I guess it doesn't have one yet.
 
Upvote 0

Forum statistics

Threads
1,215,016
Messages
6,122,700
Members
449,092
Latest member
snoom82

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