+ Reply to Thread
Results 1 to 5 of 5

resizing the image in PPT using VBA

  1. #1
    Registered User
    Join Date
    07-06-2010
    Location
    India
    MS-Off Ver
    Excel 2003
    Posts
    10

    resizing the image in PPT using VBA

    I am trying to move few charts from Excel to a PowerPoint slide as an image and resize them. I have got the code which copies the chart (as picture) from excel and pastes it in PowerPoint. Now I want to resize them as follows:

    Height of the chart– 4.5
    Width of the chart – 9.18
    Horizontal – 01.6
    Vertical – 0.7

    Can you please help me with the VBA code in changing the dimension of the image?

    Sub ExcelToExistingPowerPoint()
    Dim PPApp As PowerPoint.Application
    Dim PPPres As PowerPoint.Presentation
    Dim PPSlide As PowerPoint.Slide
    ' Reference existing instance of PowerPoint
    Set PPApp = GetObject(, "Powerpoint.Application")
    ' Reference active presentation
    Set PPPres = PPApp.ActivePresentation
    ' Some PowerPoint actions work best in normal slide view
    PPApp.ActiveWindow.ViewType = ppViewSlide

    ' Add first slide to presentation
    Set PPSlide = PPPres.Slides.Add(1, ppLayoutTitleOnly)

    ' Copy chart as a picture
    Selection.CopyPicture _
    Appearance:=xlScreen, Format:=xlPicture
    ' Paste chart
    PPSlide.Shapes.Paste.Select
    Set myChart = ActiveSheet.ChartObjects.Add(Left:=Offset, Width:=9.18, Top:=OffsetY, Height:=4.5)
    'format pic
    ' Align pasted chart
    PPApp.ActiveWindow.Selection.ShapeRange.Align msoAlignCenters, True
    PPApp.ActiveWindow.Selection.ShapeRange.Align msoAlignMiddles, True

    ' Reference active slide
    Set PPSlide = PPPres.Slides _
    (PPApp.ActiveWindow.Selection.SlideRange.SlideIndex)
    ' Save the presentation
    PPPres.Save
    ' Clean up
    Set PPSlide = Nothing
    Set PPPres = Nothing
    Set PPApp = Nothing
    End Sub

  2. #2
    Registered User
    Join Date
    07-06-2010
    Location
    India
    MS-Off Ver
    Excel 2003
    Posts
    10

    Re: resizing the image in PPT using VBA

    Can someone please help?

  3. #3
    Registered User
    Join Date
    04-03-2012
    Location
    Melbourne, Australia
    MS-Off Ver
    Excel 2007
    Posts
    1

    Cool Re: resizing the image in PPT using VBA

    Hi, this maximises all images in the presentation.


    Please Login or Register  to view this content.

  4. #4
    Registered User
    Join Date
    09-09-2012
    Location
    Colorado
    MS-Off Ver
    Excel 2010
    Posts
    1

    Re: resizing the image in PPT using VBA

    How did you define SlideMaster as in the above code?

  5. #5
    Forum Contributor arlu1201's Avatar
    Join Date
    09-09-2011
    Location
    Bangalore, India
    MS-Off Ver
    Excel 2003 & 2007
    Posts
    19,166

    Re: resizing the image in PPT using VBA

    Doll,

    Welcome to the Forum, unfortunately:

    Your post does not comply with Rule 2 of our Forum RULES. Don't post a question in the thread of another member -- start your own thread. If you feel it's particularly relevant, provide a link to the other thread. It makes sense to have a new thread for your question because a thread with numerous replies can be off putting & difficult to pick out relevant replies.
    If I have helped, Don't forget to add to my reputation (click on the star below the post)
    Don't forget to mark threads as "Solved" (Thread Tools->Mark thread as Solved)
    Use code tags when posting your VBA code: [code] Your code here [/code]

+ Reply to Thread

Thread Information

Users Browsing this Thread

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

Tags for this Thread

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