Results 1 to 26 of 26

getting Selection.OnAction to recognize correct workbook

Threaded View

  1. #1
    Registered User
    Join Date
    09-17-2013
    Location
    Connecticut
    MS-Off Ver
    Excel 2007
    Posts
    25

    getting Selection.OnAction to recognize correct workbook

    I have a routine that reduces a large monthly data set, then parses the data into individual workbooks (each month on a separate tab) for a number of different departments. The workbooks are stored online in a common directory for each department to access and update.

    In order to improve things, management wants each department to certify they have reviewed and updated the data. I've programmed a form button (as opposed to an activex button) that the user can click when they have completed their data which will send me an e-mail certification.

    I've put the e-mail code into the "ThisWorkbook" sheet of each department's workbook. The expectation is that the pointer to the e-mail code will be to the local copy in each department's workbook when the
    Selection.OnAction
    command is generated for each month in each workbook.

    The code works as advertised except that the command "
    Selection.OnAction
    = "ThisWorkbook.CertifyEmail" always tries to reference my source code, not the local department copy” (On my machine, my source code opens and runs the e-mail routine without issue - obviously I can't have my users accessing my master file)

    Here’s the code that generates the button on each month’s worksheet within each department’s file:
    Sub UpdateConfirmation()
    
     Dim x As String
     
        ActiveSheet.Buttons.Add(99.6, 51, 150, 70).Select
        x = Selection.name
        
        ' e-mail generation routine
        Selection.OnAction = "ThisWorkbook.CertifyEmail"
        
        ActiveSheet.Shapes(x).Select
        Selection.Characters.Text = _
            "Click this button to confirm you have updated " & _
            "this month's data with current information " & _
            "(an e-mail will be sent automatically)"
           
    End Sub
    Any suggestions how to get the OnAction command to reference the local code in each department's workbook?

    Art
    Last edited by alansidman; 09-30-2013 at 12:51 PM. Reason: adding tags

Thread Information

Users Browsing this Thread

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

Similar Threads

  1. [SOLVED] The selection is not a range or the sheet is protected please correct and try again
    By tigerdel in forum Excel Programming / VBA / Macros
    Replies: 3
    Last Post: 06-02-2013, 11:55 AM
  2. Replies: 1
    Last Post: 06-04-2012, 04:13 PM
  3. Correct syntax for using variable in range selection
    By coasterman in forum Excel Programming / VBA / Macros
    Replies: 6
    Last Post: 01-16-2012, 11:52 AM
  4. Assigning Onaction to control in a new workbook
    By aaronnuetzman in forum Excel Programming / VBA / Macros
    Replies: 2
    Last Post: 08-08-2010, 03:32 AM
  5. Code to recognize where selection change active cell originates
    By jman0707 in forum Excel Programming / VBA / Macros
    Replies: 0
    Last Post: 11-14-2008, 12:27 PM

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