+ Reply to Thread
Results 1 to 4 of 4

Cycle through each imagine in sheet and change it's height / width ignoring one image?

Hybrid View

  1. #1
    Forum Contributor
    Join Date
    09-07-2010
    Location
    London
    MS-Off Ver
    Excel 2010
    Posts
    358

    Cycle through each imagine in sheet and change it's height / width ignoring one image?

    Anyone know how do the following:

    Cycle through every image on a sheet without knowing their picture name OR cycle through Picture 2 to Picture 50 ignoring any what don't exist?

    And then setting their width and height to the following:
    Selection.ShapeRange.Height = 70.8661417323
    Selection.ShapeRange.Width = 87.874015748

    Thanks in advance
    - Hyflex

  2. #2
    Forum Guru xladept's Avatar
    Join Date
    04-14-2012
    Location
    Pasadena, California
    MS-Off Ver
    Excel 2003,2010
    Posts
    12,378

    Re: Cycle through each imagine in sheet and change it's height / width ignoring one image?

    Hi Hyflex,

    Try this:

    Sub ResizePics()
        Dim pic As Object, ws As Worksheet, r As Range
                      Set ws = ActiveSheet
        
        For Each pic In ws.Shapes
        If pic.Type = msoPicture Then
                   
                pic.LockAspectRatio = msoFalse
                pic.Width = 87.874015748
                pic.Height = 70.8661417323
    
        End If: Next pic: End Sub
    If I've helped you, please consider adding to my reputation - just click on the liitle star at the left.

    ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~(Pride has no aftertaste.)

    You can't do one thing. XLAdept

    ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~aka Orrin

  3. #3
    Forum Contributor
    Join Date
    09-07-2010
    Location
    London
    MS-Off Ver
    Excel 2010
    Posts
    358

    Re: Cycle through each imagine in sheet and change it's height / width ignoring one image?

    How to I make exceptions for image names?

    So Picture 1, Picture 2, Picture 5?

    Also is it possible to adjust their position from current position down 5 pixels and right 10 pixels?

  4. #4
    Forum Guru xladept's Avatar
    Join Date
    04-14-2012
    Location
    Pasadena, California
    MS-Off Ver
    Excel 2003,2010
    Posts
    12,378

    Re: Cycle through each imagine in sheet and change it's height / width ignoring one image?

    Here's one way - if you have a lot of exceptions, we should code it differently

    Sub ResizePics()
        Dim pic As Object, ws As Worksheet, r As Range, N As String
                      Set ws = ActiveSheet
        
        For Each pic In ws.Shapes
        If pic.Type = msoPicture Then
         N = pic.Name
         If N <> "Picture 1" Or N <> "Picture 2" Or N <> "Picture 5" Then
                pic.LockAspectRatio = msoFalse
                pic.Top = pic.Top + 5
                pic.Left = pic.Left + 10
                pic.Width = 87.874015748
                pic.Height = 70.8661417323
    
        End If: End If: Next pic: End Sub

+ Reply to Thread

Thread Information

Users Browsing this Thread

There are currently 1 users browsing this thread. (0 members and 1 guests)

Similar Threads

  1. Change Cylinder Height and Width from a cell value
    By korn.deuce in forum Excel Formulas & Functions
    Replies: 0
    Last Post: 01-11-2013, 11:25 AM
  2. Replies: 8
    Last Post: 10-26-2009, 09:46 AM
  3. Setting the Height and Width of an Image
    By NaNaBoo in forum Excel Programming / VBA / Macros
    Replies: 2
    Last Post: 04-02-2009, 01:36 PM
  4. Replies: 1
    Last Post: 11-13-2005, 05:15 PM
  5. How do i change the height and width of a single cell in Excel?
    By lotus1107 in forum Excel Charting & Pivots
    Replies: 1
    Last Post: 08-07-2005, 10:05 PM

Bookmarks

Posting Permissions

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

Search Engine Friendly URLs by vBSEO 3.6.0 RC 1