Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Westi on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Excel Addin Macro assignment when disributing workbook

Status
Not open for further replies.

DaOtH

Technical User
Jan 22, 2002
114
SE
Hi,

I created an Excel Addin, in it a bunch of macro's and distributed that file.
In a normal workbook i have buttons, referencing to a macro in this addin, without a link to the addin file, just the macroname itself.

When i distribute this last workbook to another user, having the addin installed as well and he opens the file and clicks the button, it states the macro can not be found, referencing the macro with it's complete name, so inclusive the add-in path. Unfortunately this path is the path to my folder and not his, so the button does not call the macro.

Hope you guys still follow me.
Anybody any idea how to resolve this ?

"In three words I can sum up everything I've learned about life: it goes on."
- Robert Frost 1874-1963
 



You must send the addin so he can install.

Skip,
[glasses]Don't let the Diatribe...
talk you to death![tongue]

[glasses]Just traded in my old subtlety...
for a NUANCE![tongue]
 
Yep, that part i was able to figure out already, that's not the issue.

He has the addin installed and it works properly.
Nevertheless, the button on in the file i then send him tries to execute the macro in the .xla file in my add-ins folder instead of his own.

"In three words I can sum up everything I've learned about life: it goes on."
- Robert Frost 1874-1963
 


Because the workbook you sent him has your addin referenced.

Unreference. The send.

Skip,
[glasses]Don't let the Diatribe...
talk you to death![tongue]

[glasses]Just traded in my old subtlety...
for a NUANCE![tongue]
 
Nope, not referenced, did that double check myself already before posting this question.


"In three words I can sum up everything I've learned about life: it goes on."
- Robert Frost 1874-1963
 
Right,

I appear to be able to avoid the problem by implementing the following code in each workbook, however i still find it funny behaviour.
(and now i need to find a way to insert this code in each new workbook i create though the addin)

Code:
Private Sub workbook_Open()
On Error GoTo Error_Handler
    Dim intI As Integer
    Dim wSheet As Worksheet
    Dim strOnAction As String
    
        Application.ScreenUpdating = False
        For Each wSheet In Worksheets
            For intI = 1 To wSheet.Buttons.Count
                strOnAction = wSheet.Buttons(intI).OnAction
                strOnAction = Right(strOnAction, Len(strOnAction) - InStr(strOnAction, "!"))
                wSheet.Buttons(intI).OnAction = strOnAction
            Next intI
        Next wSheet
        Application.ScreenUpdating = True
    Exit Sub
Error_Handler:
        Application.ScreenUpdating = True
End Sub

"In three words I can sum up everything I've learned about life: it goes on."
- Robert Frost 1874-1963
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top