+ Reply to Thread
Results 1 to 5 of 5

Rightclick macro if cell contents formatted correctly

  1. #1
    Registered User
    Join Date
    02-27-2008
    Location
    Irving, Texas
    MS-Off Ver
    MS Office 2016
    Posts
    96

    Rightclick macro if cell contents formatted correctly

    Hi all,

    I'm attempting to create something that can be used on any workbook open to automatically open a file based on the data in cell. Here's the general idea:

    1) User right clicks on a cell.
    2) If the cell's value matches an expected format (##-A-####-## for example), a macro is available in the rightclick popup menu.
    3) The user selects the macro in the popup menu if they want to run it.
    4) The macro takes the cell value and converts it into a filename.
    5) The specified file is opened in an external program.


    I have everything done for steps 4 and 5, in the following code:

    Please Login or Register  to view this content.
    The rightclick stuff is a bit more difficult for me. I think I need to get into the BeforeRightClick event, but I'm not sure how to use it and I don't know how to make it so that each user need only add the macro once and then have it available for every workbook from then on.

    Any suggestions would be greatly appreciated!
    Last edited by ahartman; 01-20-2009 at 02:30 PM. Reason: Premature post
    -Adam Hartman
    Mechanical Engineer

  2. #2
    Forum Contributor
    Join Date
    04-21-2007
    Location
    Lima, Peru
    MS-Off Ver
    2000, 2007, 2010
    Posts
    674

    Right click macro

    Hi

    The following link covers most of what you are looking for and you can probably add an appropriate condition.

    http://www.ozgrid.com/VBA/right-click.htm

    Regards

    Jeff
    Last edited by VBA Noob; 01-16-2009 at 03:44 PM.

  3. #3
    Registered User
    Join Date
    02-27-2008
    Location
    Irving, Texas
    MS-Off Ver
    MS Office 2016
    Posts
    96
    Quote Originally Posted by solnajeff View Post
    Hi

    The following link covers most of what you are looking for and you can probably add an appropriate condition.

    http://www.ozgrid.com/VBA/right-click.htm

    Regards

    Jeff
    Thanks for the link. Looking at it, I'm not sure if it will apply to any workbook, or if the user would have to add it to each book before they can use it. My thinking is that I could make something to go in personal.xls, and then each user would only have to put it in there once.

  4. #4
    Forum Contributor
    Join Date
    04-21-2007
    Location
    Lima, Peru
    MS-Off Ver
    2000, 2007, 2010
    Posts
    674

    Right click menu

    Hi

    I tried out the code and it works fine, but the proviso is that it has to go in the ThisWorkbook module and I doubt that you could get around that using Personal.xls as whatever happens you would need code to link it to the Personal workbook.

    Regards

    Jeff

  5. #5
    Registered User
    Join Date
    02-27-2008
    Location
    Irving, Texas
    MS-Off Ver
    MS Office 2016
    Posts
    96
    Jeff,

    FYI, I've been able to get this code to be available to any workbook open in excel by saving it as an XLA, and setting the temporary:= value to true in the following section in the right click code:

    Please Login or Register  to view this content.
    The user just needs to add-in the XLA file one time, and I think use the right click functionality once on the XLA workbook, and then it's there in their right click menu. I assume it can be removed by getting rid of the XLA file, but I've not tried that, yet.

+ 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