Results 1 to 8 of 8
  1. #1
    Silver Lounger
    Join Date
    Mar 2001
    Location
    Springfield, Ohio, USA
    Posts
    2,136
    Thanks
    0
    Thanked 1 Time in 1 Post

    Select Crop Tool with VBA (XL 2000)

    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?
    <font face="Comic Sans MS">Sam Barrett, CACI </font face=comic>
    <small>And the things that you have heard... commit these to faithful men who will be able to teach others also. 2 Timothy 2:2</small>

  2. #2
    Plutonium Lounger
    Join Date
    Mar 2002
    Posts
    84,353
    Thanks
    0
    Thanked 29 Times in 29 Posts

    Re: Select Crop Tool with VBA (XL 2000)

    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

  3. #3
    Silver Lounger
    Join Date
    Mar 2001
    Location
    Springfield, Ohio, USA
    Posts
    2,136
    Thanks
    0
    Thanked 1 Time in 1 Post

    Re: Select Crop Tool with VBA (XL 2000)

    Just want to select the tool
    <font face="Comic Sans MS">Sam Barrett, CACI </font face=comic>
    <small>And the things that you have heard... commit these to faithful men who will be able to teach others also. 2 Timothy 2:2</small>

  4. #4
    Plutonium Lounger
    Join Date
    Mar 2002
    Posts
    84,353
    Thanks
    0
    Thanked 29 Times in 29 Posts

    Re: Select Crop Tool with VBA (XL 2000)

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

  5. #5
    Silver Lounger
    Join Date
    Mar 2001
    Location
    Springfield, Ohio, USA
    Posts
    2,136
    Thanks
    0
    Thanked 1 Time in 1 Post

    Re: Select Crop Tool with VBA (XL 2000)

    What! <img src=/S/drop.gif border=0 alt=drop width=23 height=23>
    <font face="Comic Sans MS">Sam Barrett, CACI </font face=comic>
    <small>And the things that you have heard... commit these to faithful men who will be able to teach others also. 2 Timothy 2:2</small>

  6. #6
    Plutonium Lounger
    Join Date
    Mar 2002
    Posts
    84,353
    Thanks
    0
    Thanked 29 Times in 29 Posts

    Re: Select Crop Tool with VBA (XL 2000)

    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.

  7. #7
    Silver Lounger
    Join Date
    Mar 2001
    Location
    Springfield, Ohio, USA
    Posts
    2,136
    Thanks
    0
    Thanked 1 Time in 1 Post

    Re: Select Crop Tool with VBA (XL 2000)

    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:
    <pre> Application.CommandBars("Picture").FindControl(ID: =732).Execute</pre>


    Thanks anyway! I was just feeling lazy today (320 images to crop).
    <font face="Comic Sans MS">Sam Barrett, CACI </font face=comic>
    <small>And the things that you have heard... commit these to faithful men who will be able to teach others also. 2 Timothy 2:2</small>

  8. #8
    Plutonium Lounger
    Join Date
    Mar 2002
    Posts
    84,353
    Thanks
    0
    Thanked 29 Times in 29 Posts

    Re: Select Crop Tool with VBA (XL 2000)

    OK, thanks for posting the solution.

Posting Permissions

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