• Select Crop Tool with VBA (XL 2000)

    Author
    Topic
    #441506

    I have a macro which inserts a picture into my spreadsheet. The last line is
    ActiveSheet.Pictures.Insert(s).Select

    I use .Select, because I need to crop the image. But, I would rather not have to click in the Picture Toolbar to select the Crop tool. How do I do this in code?

    Viewing 0 reply threads
    Author
    Replies
    • #1060363

      Do you really want to select the crop tool in code, or do you want to crop the image in code? For the latter, you can use something like

      With ActiveSheet.Shapes(1)
      .PictureFormat.CropRight = .Width * 0.1
      End With

      • #1060364

        Just want to select the tool

        • #1060369

          I don’t know of a way to do that in code.

          • #1060371

            What! drop

            • #1060385

              As far as I know, it is not possible, and frankly I don’t see why it would be desirable. If you want to crop using code, the CropLeft, CropTop etc. methods are available. If you crop manually, you crop … er, well, manually. You cannot do that while a macro is running, so selecting the crop tool in code doesn’t make much sense to me. Sorry.

            • #1060388

              I have to manually crop each image, so it is one less mouse-click if I preselect the crop tool. Just tried .Execute & it works:

                  Application.CommandBars("Picture").FindControl(ID:=732).Execute

              Thanks anyway! I was just feeling lazy today (320 images to crop).

            • #1060390

              OK, thanks for posting the solution.

    Viewing 0 reply threads
    Reply To: Select Crop Tool with VBA (XL 2000)

    You can use BBCodes to format your content.
    Your account can't use all available BBCodes, they will be stripped before saving.

    Your information: