+ Reply to Thread
Results 1 to 4 of 4

Unable to change image height, width, left, top in PowerPoint 2013

Hybrid View

  1. #1
    Registered User
    Join Date
    01-22-2014
    Location
    Denver, Colorado
    MS-Off Ver
    Excel 2010
    Posts
    3

    Unable to change image height, width, left, top in PowerPoint 2013

    Hello experts,

    I have an application that copies ranges/charts from Excel as images and pastes them into PowerPoint. I then run the image thru a subroutine to set the location within the slide. My problem is that this works just fine in PowerPoint 2010 but doesn't work in PowerPoint 2013. I don't get any error messages, but it bombs out of the sub immediately after pasting the image.

    Here is the code of the sub in question:

    Sub FormatShape(ppApp As PowerPoint.Application, ppSlide As PowerPoint.Slide, SHHeight, SHWidth, SHLeft, SHTop, LockRatio)
                     
        Dim ppShape As PowerPoint.ShapeRange
    
        Set ppShape = ppSlide.Shapes.Paste   'exits immediately after this!
            
        With ppShape
                
            If LockRatio = "True" Then
                .LockAspectRatio = msoTrue
            ElseIf LockRatio = "False" Then
                .LockAspectRatio = msoFalse
            End If
                
            .Height = SHHeight
            .Width = SHWidth
            .Left = SHLeft
            .Top = SHTop
    
        End With
        
        Set ppShape = Nothing
        
    End Sub

  2. #2
    Administrator 6StringJazzer's Avatar
    Join Date
    01-27-2010
    Location
    Tysons Corner, VA, USA
    MS-Off Ver
    MS 365 Family 64-bit 2502
    Posts
    26,770

    Re: Unable to change image height, width, left, top in PowerPoint 2013

    Maybe you are not properly linked to the library that has msoTrue and msoFalse. I would not think you have to do anything special to get them but it's the only unusual thing I see here. They are the choices that the autocomplete feature offers, so maybe that's not ythe problem, but try the change in red and see what happens:

    Sub FormatShape(ppApp As PowerPoint.Application, ppSlide As PowerPoint.Slide, SHHeight, SHWidth, SHLeft, SHTop, LockRatio)
                     
        Dim ppShape As PowerPoint.ShapeRange
    
        Set ppShape = ppSlide.Shapes.Paste   'exits immediately after this!
            
        With ppShape
                
            .LockAspectRatio = LockRatio
                
            .Height = SHHeight
            .Width = SHWidth
            .Left = SHLeft
            .Top = SHTop
    
        End With
        
        Set ppShape = Nothing
        
    End Sub
    Jeff
    | | |會 |會 |會 |會 | |:| | |會 |會
    Read the rules
    Use code tags to [code]enclose your code![/code]

  3. #3
    Registered User
    Join Date
    01-22-2014
    Location
    Denver, Colorado
    MS-Off Ver
    Excel 2010
    Posts
    3

    Re: Unable to change image height, width, left, top in PowerPoint 2013

    Thanks Jeff. Unfortunately that didn't solve the problem. In fact, I can simply execute the code like shown below and it will still exit on the same row, regardless what the next line contains. It is almost as if it doesn't know what to do with ppShape. I've tried dimming ppShape as 'Shape', 'ShapeRange', and 'PowerPoint.Shape', but none of them even execute the paste line.

    Sub FormatShape(ppApp As PowerPoint.Application, ppSlide As PowerPoint.Slide, SHHeight, SHWidth, SHLeft, SHTop, LockRatio)
                     
        Dim ppShape As PowerPoint.ShapeRange
    
        Set ppShape = ppSlide.Shapes.Paste   'exits immediately after this!
                
        ppShape.Height = SHHeight
        ppShape.Width = SHWidth
        ppShape.Left = SHLeft
        ppShape.Top = SHTop
       
        Set ppShape = Nothing
        
    End Sub

  4. #4
    Registered User
    Join Date
    01-22-2014
    Location
    Denver, Colorado
    MS-Off Ver
    Excel 2010
    Posts
    3

    Re: Unable to change image height, width, left, top in PowerPoint 2013

    For what it's worth, I know I can workaround the issue using the code below, but I don't necessarily like this workaround as it seems too risky. It also doesn't answer why I can't set ppShape in my previous code sample.

    Sub FormatShape(ppApp As PowerPoint.Application, ppSlide As PowerPoint.Slide, SHHeight, SHWidth, SHLeft, SHTop, LockRatio)
                                    
    
        If Application.Version = 14# Then
            ppSlide.Shapes.Paste.Select           'works in Office 2010 but not in Office 2013
        ElseIf Application.Version = 15# Then
            ppSlide.Shapes.Paste                  'works in Office 2013 but not in Office 2010
        End If
                           
    
        If LockRatio = "True" Then
            ppApp.ActiveWindow.Selection.ShapeRange.LockAspectRatio = msoTrue
        ElseIf LockRatio = "False" Then
             ppApp.ActiveWindow.Selection.ShapeRange.LockAspectRatio = msoFalse
        End If
                
    
        ppApp.ActiveWindow.Selection.ShapeRange.Height = SHHeight
        ppApp.ActiveWindow.Selection.ShapeRange.Width = SHWidth
                
        ppApp.ActiveWindow.Selection.ShapeRange.Left = SHLeft
        ppApp.ActiveWindow.Selection.ShapeRange.Top = SHTop
    
    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. [SOLVED] Cycle through each imagine in sheet and change it's height / width ignoring one image?
    By Hyflex in forum Excel Programming / VBA / Macros
    Replies: 3
    Last Post: 09-13-2013, 03:49 PM
  2. 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
  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. 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
  5. .AddShape(Type, Left, Top, Width, Height)
    By AA2e72E in forum Excel Programming / VBA / Macros
    Replies: 2
    Last Post: 02-02-2005, 10:06 AM

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