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

Which came first: VisiCalc or Lotus 1-2-3?
Dan Bricklin and Bob Frankston debuted VisiCalc in 1979 as a Visible Calculator. Lotus 1-2-3 debuted in the early 1980's, from Mitch Kapor.
Hello Colin

What is your code to do it on 1 workbook?
 
Upvote 0
What macro do you execute in the addin?
Did you use the macro recorder to explore some generated code?
 
Upvote 0
There's isn't a macro to run the add-in, the add-in has a built in refresh button that you select
 
Upvote 0
In that case, you could try to see what macro is behind the refresh button.
Or is it merely a recalculation that is triggered?
 
Upvote 0
The actual code behind the add-in is password protect so can't view it but I've just been told this bit of code can activate the refresh part of the add-inn


<code>Run ("</code>HRwsBTH<code>.xla!Refresh"), True</code></pre>
 
Upvote 0
In that case, loop over the files (Dir function) and execute that line of code:

Code:
Sub GetFilesInLoop()

Dim FileName As String


'Edit this declaration to your folder name
FilePath = "C:\myfiles"


FileName = Dir(FilePath & "\*.xls")


Do While FileName <> vbNullString


    With Workbooks.Open(FilePath & "\" & FileName)
        Run "HRwsBTH.xla!Refresh"
        .Save
        .Saved = True
        .Close 0
    End With
    FileName = Dir()
Loop


End Sub
 
Upvote 0
Would I be right in thinking since I have 20+ workbooks the code would look like this:

Code:
Sub GetFilesInLoop()

Dim FileName As String


'Edit this declaration to your folder name
FilePath = "C:\myfiles"


FileName = Dir(FilePath & "\Workbook1.xls")
FileName = Dir(FilePath & "\Workbook2.xls")
FileName = Dir(FilePath & "\Workbook3.xls")
FileName = Dir(FilePath & "\Workbook4.xls")

'and so on....


Do While FileName <> vbNullString


    With Workbooks.Open(FilePath & "\" & FileName)
        Run "HRwsBTH.xla!Refresh"
        .Save
        .Saved = True
        .Close 0
    End With
    FileName = Dir()
Loop


End Sub
 
Last edited:
Upvote 0
No, that is not right. The Dir() function and the Do While Loop take care of searching the files.
Within that loop, each file is opened and the one statement you already had, is executed.
You have to provide the folder name, not all individual file names.
 
Upvote 0

Forum statistics

Threads
1,223,243
Messages
6,170,964
Members
452,371
Latest member
Frana

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