none
How to call the Word ribbon Crop button from a macro RRS feed

  • Question

  • I want to select a picture in Word and then call the Crop button from a VBA macro. Is there any way to do that? I can't see the name of the crop operation in any macro list and have not been able to find any suitable code on the net. I've seen things like 'Item.GetInspector.CommandBars.ExecuteMso "MoveToOneNote" and "Application.CommadBars.ExecuteMso SomeMsoID", but nothing I found worked.

    Is it possible to call ribbon buttons from VBA macros? If so, how? Thank you.

    Tuesday, March 3, 2020 2:53 AM

All replies

  • You can download the commands for all Office 2016 applications from https://www.microsoft.com/en-us/download/details.aspx?id=50745

    To display the crop marks around the edge of a picture, you can use

        Application.CommandBars.ExecuteMso("PictureCrop"


    If you want to specify how to crop a picture in your macro, use code like this:

    Sub CropPicture()
        With ActiveDocument.InlineShapes(1).PictureFormat
            .CropTop = 24
            .CropLeft = 36
            .CropBottom = 24
            .CropRight = 36
        End With
    End Sub

    The numbers represent points, where 1 inch = 72 points.


    Regards, Hans Vogelaar (http://www.eileenslounge.com)


    Tuesday, March 3, 2020 11:22 AM