+ Reply to Thread
Results 1 to 2 of 2

Code for multiple email command buttons

Hybrid View

  1. #1
    Registered User
    Join Date
    07-01-2010
    Location
    adelaide
    MS-Off Ver
    Excel 2003
    Posts
    86

    Code for multiple email command buttons

    Could someone please help,

    I have a workbook that i have 3 command buttons on the first worksheet page

    eg.
    button 1 is email service
    button 2 email install
    button 3 email sales person.

    i want to be able to send to the correct department the whole workbook based on which button i press.

    I have seen the other links which doesnt have the code for having multiple buttons on the same page.

    Please help

  2. #2
    Forum Expert
    Join Date
    03-31-2009
    Location
    Barstow, Ca
    MS-Off Ver
    Excel 2002 & 2007
    Posts
    2,164

    Re: Code for mulitple email command buttons

    I'm guessing that you want your macro to know which department to send the email to. And that you have macros to send the email.

    Assign this macro to ALL 3 buttons. Modify to fit your workbook.
    Sub Button_Click()
        Dim s As String
        Dim oButton as Object
    
        On Error Resume Next
        s = Application.Caller
        On Error GoTo 0
    
        If s <> "" Then    
            On Error Resume Next
            Set oButton = ActiveSheet.buttons(s)
            On Error GoTo 0
    
            If Not oButton is Nothing Then
                Select Case Trim(oButton.Caption)
                    Case "Service"
                        'Send email to Service Dept
                        '.... your code
                    Case "Install"
                        'Send email to Install Dept
                        '.... your code
                    Case "Sales Person"
                        'Send email to Sales Person
                        '.... your code
                End Select
            End If
        End If
    End Sub
    Foxguy

    Remember to mark your questions [Solved] and rate the answer(s)
    Forum Rules are Here

+ Reply to Thread

Thread Information

Users Browsing this Thread

There are currently 1 users browsing this thread. (0 members and 1 guests)

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts

Search Engine Friendly URLs by vBSEO 3.6.0 RC 1