Run an Add-in from another workbook

TheCman81

Well-known Member
Joined
Feb 28, 2012
Messages
535
Hi All,

Thanks in advance.

Excel 2007

I'm looking for a macro to run the same Add-In on various different workbooks. Add-In name is "HRwsBTH"

I have about 20+ workbooks that I need to open and manually refresh my Add-In and it's very time consuming.

So what I would like to achieve with the macro is the following:

1. Open a file
2. Run the Add-In
3. Save the file
4. Close the workbook

I need these steps repeated for each workbook

Thanks

Colin
 

Excel Facts

Excel Joke
Why can't spreadsheets drive cars? They crash too often!
Also one more thing which I've just remembered, every workbook is in a different folder so they won't have the same file path
 
Upvote 0
I took the stance that all workbooks reside in the same folder. Dir() can loop through them easily.
If not, you'll have to specify the folders and (possibly) the file names.
for example, looping through column A in a certain file, which contains the exact paths and file names.
You'll find such coding a lot on boards like MrExcel, especially with 300+ posts you will certainly be able to find such similar codes.
 
Upvote 0
I always search before I post anything and I couldn't find anything that fits my situation! Hence why I'm looking for help with this.

Any help would be appreciated

Thanks

C
 
Upvote 0
With respect to my previous post - how are you going to use it?
Will you specify all folders and filenames? How should the code be able to "find" the files to be opened?
 
Upvote 0
I could list all file paths on one column like you suggested in the last post if that makes for easier coding?
Due to having 20+ workbooks I would prefer it if one file is opened at a time

Cheers
 
Upvote 0
If you list (only) the file paths, does this mean that the filename is always the same?
 
Upvote 0
If you use column A cells to provide (correct!) paths and filenames, this could work:

Code:
Sub GetFilesInLoop()
    Application.ScreenUpdating = True


    For Each c In Columns(1).SpecialCells(2, 2)
        
        With Workbooks.Open(c.Text)
            Run "HRwsBTH.xla!Refresh"
            .Save
            .Saved = True
            .Close 0
        End With
        
    Next


End Sub
 
Upvote 0

Forum statistics

Threads
1,223,247
Messages
6,171,004
Members
452,374
Latest member
keccles

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