T
Tony WONG
i have a small program to send emails by outlook in excel.
not sure what's go wrong, the VBA run twice when "the button" is clicked.
however if i run VBA in the editor, it is normal to run once.
therefore, i think it is wrong with "the button" created by "Workbook_Open"
when i open the excel.
any assistance on it? Thanks a lot.
****************************
Private Sub Workbook_BeforeClose(Cancel As Boolean)
On Error Resume Next
Application.CommandBars("Worksheet Menu Bar").Controls("SendMail").Delete
End Sub
Private Sub Workbook_Open()
Dim mybutton1 As CommandBarButton
Set mybutton1 = Application.CommandBars("Worksheet Menu Bar").Controls.Add
With mybutton1
.Caption = "SendMail"
.Style = msoButtonCaption
.BeginGroup = False
.OnAction = "Sheet1.Sendmail()"
End With
End Sub
not sure what's go wrong, the VBA run twice when "the button" is clicked.
however if i run VBA in the editor, it is normal to run once.
therefore, i think it is wrong with "the button" created by "Workbook_Open"
when i open the excel.
any assistance on it? Thanks a lot.
****************************
Private Sub Workbook_BeforeClose(Cancel As Boolean)
On Error Resume Next
Application.CommandBars("Worksheet Menu Bar").Controls("SendMail").Delete
End Sub
Private Sub Workbook_Open()
Dim mybutton1 As CommandBarButton
Set mybutton1 = Application.CommandBars("Worksheet Menu Bar").Controls.Add
With mybutton1
.Caption = "SendMail"
.Style = msoButtonCaption
.BeginGroup = False
.OnAction = "Sheet1.Sendmail()"
End With
End Sub