Microsoft Office Forums

Go Back   Microsoft Office Forums > >

Reply
 
Thread Tools Display Modes
  #1  
Old 03-03-2020, 08:47 AM
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: 613
jeffreybrown has a spectacular aura aboutjeffreybrown has a spectacular aura about
Default Paste shape from Excel

I'm taking a shape from Excel and would like to fill the slide in ppt.



This below is fine, but how can it stretch from the left to the right?

Code:
    With PPSlide
        .Shapes.Paste.Select
        With .Shapes(.Shapes.Count)
            .LockAspectRatio = msoTrue
            .Left = 15
            .Top = 100
            .Height = 400
        End With
Reply With Quote
  #2  
Old 03-04-2020, 07:52 AM
JohnWilson JohnWilson is offline Paste shape from Excel Windows 10 Paste shape from Excel Office 2016
Programmer
 
Join Date: Nov 2008
Location: UK
Posts: 1,822
JohnWilson will become famous soon enoughJohnWilson will become famous soon enough
Default

Is this code running in Excel or PowerPoint. and can you include the full code.
__________________
Microsoft PowerPoint MVP
Free Advanced PowerPoint Tips and Tutorials
Reply With Quote
  #3  
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: 613
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
  #4  
Old 03-06-2020, 09:02 AM
JohnWilson JohnWilson is offline Paste shape from Excel Windows 10 Paste shape from Excel Office 2016
Programmer
 
Join Date: Nov 2008
Location: UK
Posts: 1,822
JohnWilson will become famous soon enoughJohnWilson will become famous soon enough
Default

Maybe I'm misunderstanding but maybe use

Code:
 With PPSlide
        .Shapes.Paste.Select
       
        With .Shapes(.Shapes.Count)
            .LockAspectRatio = msoFalse
            .Left = 0
            .Top = 0
            .Width = PPApp.PageSetup.SlideWidth
            .Height = PPApp.PageSetup.SlideHeight
        End With
    End With
__________________
Microsoft PowerPoint MVP
Free Advanced PowerPoint Tips and Tutorials
Reply With Quote
  #5  
Old 03-06-2020, 01:54 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: 613
jeffreybrown has a spectacular aura aboutjeffreybrown has a spectacular aura about
Default

Thanks John. This will work.
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 - Senior Forums

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


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