aru_aakash
Board Regular
- Joined
- May 22, 2009
- Messages
- 74
Hello,
I was trying to add a procedure in Worksheet menu bar and wanted it to pass on to my colleagues through sharing of worksheet itself.
So i put following codes in a worksheet:
<Code>
Private Sub Workbook_Open()
On Error Resume Next
AddIns.Add ThisWorkbook.FullName
AddIns("InWordsRs").Installed = True
Application.CommandBars("Worksheet Menu Bar").Controls("InWordsRs").Delete
Set cControl = Application.CommandBars("Worksheet Menu Bar").Controls.Add
With cControl
.Caption = "InWordsRs"
.Style = msoButtonCaption
.OnAction = "aakash"
End With
On Error GoTo 0
End Sub
</Code>
I believed that for the commandbutton to add under "add-ins" tab, we just needed to open the workbook in which above codes are saved just once (Trigerring Workbook open event). However, once the excel is closed and again reopened, it adds one more command button with the same name (i.e "InWordsRs").
I am little confused about why this is happening. I will appreciate help from excel gurus.
2nd question : Is there any way of embedding a UDF in excel just like any other Excel's in-built function and if so how it could be done.
Many Thanks in advance
I was trying to add a procedure in Worksheet menu bar and wanted it to pass on to my colleagues through sharing of worksheet itself.
So i put following codes in a worksheet:
<Code>
Private Sub Workbook_Open()
On Error Resume Next
AddIns.Add ThisWorkbook.FullName
AddIns("InWordsRs").Installed = True
Application.CommandBars("Worksheet Menu Bar").Controls("InWordsRs").Delete
Set cControl = Application.CommandBars("Worksheet Menu Bar").Controls.Add
With cControl
.Caption = "InWordsRs"
.Style = msoButtonCaption
.OnAction = "aakash"
End With
On Error GoTo 0
End Sub
</Code>
I believed that for the commandbutton to add under "add-ins" tab, we just needed to open the workbook in which above codes are saved just once (Trigerring Workbook open event). However, once the excel is closed and again reopened, it adds one more command button with the same name (i.e "InWordsRs").
I am little confused about why this is happening. I will appreciate help from excel gurus.
2nd question : Is there any way of embedding a UDF in excel just like any other Excel's in-built function and if so how it could be done.
Many Thanks in advance