Any way to invoke this "color eyedropper" tool via vba?

Here's what I'd like to be able to do.

You have a rectangle with no fill but inside this rectangle you have two others. The key is that the outer rectangle is in front of all others. If you grab the regular eyedropper tool that's on the main toolbar you can "pluck" the color from any shape but you cannot fill any shape that's within the outer "front" rectangle. Would be nice if I could grab the one I want to change and either have an option to "fill from other shape" whereby invoking the arrow to let me choose the other shape OR hit a macro shortcut to invoke the other eyedropper tool in the image above.

Parents
  • This doesn't follow the workflow that you describe, but perhaps it would work for you:

    Option Explicit
    
    Dim fillStored As Fill
    
    Sub store_fill_from_selection()
    
    Dim sr As ShapeRange
    
        Set sr = ActiveSelectionRange
        If sr.Count = 1 Then
            Set fillStored = ActiveShape.Fill.GetCopy
        Else
            MsgBox "Exactly one shape must be selected.", vbInformation, "get_fill_from_object()"
        End If
    End Sub
    
    Sub apply_stored_fill_to_selection()
    
    Dim sr As ShapeRange
    Dim s As Shape
    
        Set sr = ActiveSelectionRange
        If sr.Count > 0 Then
            For Each s In sr
                s.Fill = fillStored
            Next s
        Else
            MsgBox "Nothing is selected.", vbInformation, "apply_stored_fill_to_object()"
        End If
    End Sub
    

    If you add those as Commands to some of the right-click context menus that are available when objects are selected, or assign keyboard shortcuts to them, those might be useful if you have to do a lot of  "get fill from A, then apply it to B, C, D, J, K, L,..." You don't have to use the color right away after storing it, either, as it will be persistent for the CorelDRAW session.

    In the thread I had linked to, you noted some problems using the Ctrl+Shift+E with different color spaces. I don't think that will be a problem with this macro; it's using the fill, not sampling a color the way the eyedropper tool does.

    Bonus: not limited to uniform color fills!

    You can of course polish it up, e.g., using a CommandGroup for the apply operation, adding error handling, adding validation of the selection...

Reply Children