Consulting

Results 1 to 4 of 4

Thread: Solved: Trapping a FillDown event

  1. #1
    VBAX Regular
    Joined
    Jun 2009
    Posts
    10
    Location

    Question Solved: Trapping a FillDown event

    I'd like to usurp the normal behaviour for filling cells (down or up), that is, I think I need to trap the event that user has selected a cell then moved the cursor to the bottom right corner and watched it change to a plus sign.

    But that does not seem to be a trappable event, at least, there is no event handler for it in the usual drop-down list or anywhere I can see in help or web search.

    If I can't do anything else, I would at least like to be able to stop users from doing this at all. (But - I can't just disable events, I need all the usual event traps active.)

    Failing that, does anyone know the name of the menu that follows right-click select-for-fill, and if I modify that right-click menu, and use it to call the function I really want, can I prevent the subsequent fill?

    But the ideal I am really hoping for is to allow a user to do go through the entire process of selecting a range with the plus sign, using either right or left click and drag, indicating it would be filled, but then usurp the .FillDown method itself to do something other than .FillDown.

    Any pointers?

  2. #2
    Knowledge Base Approver VBAX Master Oorang's Avatar
    Joined
    Jan 2007
    Posts
    1,135
    Location
    Good question. I don't think you can trap that feature. You can disable it with:
    [VBA]Excel.Application.CellDragAndDrop = false[/VBA]

    And I believe the commandbar you asked about is named "AutoFill"
    Cordially,
    Aaron



    Keep Our Board Clean!
    • Please Mark your thread "Solved" if you get an acceptable response (under thread tools).
    • Enclose your code in VBA tags then it will be formatted as per the VBIDE to improve readability.

  3. #3
    VBAX Regular
    Joined
    Jun 2009
    Posts
    10
    Location
    Thanks very much indeed for those pointers.

    I did rather suspect the answer to the trap question might be "you cannot" !

    I'd still like to know how to overwrite a built-in method but I guess that is really a different and more generic question I will start in a new thread.

  4. #4
    Knowledge Base Approver VBAX Master Oorang's Avatar
    Joined
    Jan 2007
    Posts
    1,135
    Location
    Unfortunately VBA only supports a very small feature set of OOP. If you want to get "fancy" you need to use C#. You can do basic things like using a function with the same name and parameters to intercept unprefixed, and if the object has events you can intercept those using the "WithEvents" keyword. But there are some very real limitations.

    An silly example of using scope to overide a call to the msgbox is here: http://www.vbaexpress.com/forum/showthread.php?t=25809
    Cordially,
    Aaron



    Keep Our Board Clean!
    • Please Mark your thread "Solved" if you get an acceptable response (under thread tools).
    • Enclose your code in VBA tags then it will be formatted as per the VBIDE to improve readability.

Posting Permissions

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