Microsoft Office Forums

Go Back   Microsoft Office Forums > >

Reply
 
Thread Tools Display Modes
  #1  
Old 03-05-2020, 05:00 PM
jeffreybrown jeffreybrown is offline Paste shape from Excel Windows 10 Paste shape from Excel Office 2016
Expert
Paste shape from Excel
 
Join Date: Apr 2016
Posts: 673
jeffreybrown has a spectacular aura aboutjeffreybrown has a spectacular aura about
Default

Hi John,

I'm running the code from Excel. This seems to size the shape okay, but most likely a better way to fill the ppt slide.



Code:
Sub Chart_Module()
    Dim PPPres      As Object
    Dim PPApp       As Object
    Dim PPSlide     As Object
    Dim SlideCount  As Long
    Dim strFile     As String: strFile = "Charts.pptx"

    On Error Resume Next
    Set PPApp = GetObject(Class:="PowerPoint.Application")
    If PPApp Is Nothing Then
        Set PPApp = CreateObject(Class:="PowerPoint.Application")
    Else
        Set PPPres = PPApp.Presentations(strFile)
    End If
    On Error GoTo 0

    If PPPres Is Nothing Then
        Set PPPres = PPApp.Presentations.Open(ActiveWorkbook.Path & Application.PathSeparator & strFile)
    Else
    End If

    PPApp.ActiveWindow.ViewType = 1

    ActiveSheet.Shapes(3).Copy
    SlideCount = PPPres.Slides.Count
    Set PPSlide = PPPres.Slides.Add(SlideCount + 1, 11)
    PPApp.ActiveWindow.View.GotoSlide PPSlide.SlideIndex
    
    With PPSlide
        .Shapes.Paste.Select
        With .Shapes(.Shapes.Count)
            .LockAspectRatio = msoTrue
            .Left = 15
            .Top = 100
            .Height = 400
        End With
        With .Shapes(.Shapes.Count)
            .LockAspectRatio = msoFalse
            .Width = 690
        End With
    End With

End Sub
Reply With Quote
Reply

Thread Tools
Display Modes


Similar Threads
Thread Thread Starter Forum Replies Last Post
Paste an image in to a set sized shape/container you Visio 1 01-08-2020 09:32 PM
draw and save a shape that will be used in excel jerome Visio 5 05-12-2018 03:41 AM
Paste shape from Excel how to paste text as shape bsapaka Excel 1 05-01-2014 06:53 AM
Paste shape from Excel Excel vba adding field in word table/shape in a header Hdr Excel 1 02-04-2013 04:40 PM
Paste special an Excel range into Outlook as an Excel Worksheet charlesh3 Excel Programming 3 02-04-2013 04:33 PM

Other Forums: Access Forums

All times are GMT -7. The time now is 12:04 AM.


Powered by vBulletin® Version 3.8.11
Copyright ©2000 - 2025, vBulletin Solutions Inc.
Search Engine Optimisation provided by DragonByte SEO (Lite) - vBulletin Mods & Addons Copyright © 2025 DragonByte Technologies Ltd.
MSOfficeForums.com is not affiliated with Microsoft