gpt4 book ai didi

excel - 从excel(Excel VBA)插入后在PowerPoint中调整图表大小

转载 作者:行者123 更新时间:2023-12-04 21:40:45 25 4
gpt4 key购买 nike

我有一些代码在 中获取图表并将其粘贴到 幻灯片中。但是,一旦它被粘贴到 我不知道如何调整图表的大小。我已经研究过它是哪个数字“形状”,我​​可以手动执行此操作,但我不知道如何自动执行此操作。任何帮助将不胜感激,谢谢!

这是我的代码:

Sub AddChartToPPT(PPT As PowerPoint.Application, Slide As Integer, Chart As String, FromTop As Double, FromLeft As Double, Length As Double, Width As Double)
Dim activeslide As PowerPoint.Slide
PPT.ActiveWindow.View.GotoSlide Slide
Set activeslide = PPT.ActivePresentation.Slides(Slide)
ActiveSheet.ChartObjects(Chart).Activate
ActiveChart.ChartArea.Copy
activeslide.Shapes.PasteSpecial(DataType:=ppPasteMetafilePicture).Select
PPT.ActiveWindow.Selection.ShapeRange.Left = FromLeft
PPT.ActiveWindow.Selection.ShapeRange.Top = FromTop
'Need to add scaling code
End Sub

最佳答案

尝试这个:

dim shp as Object
set shp=activeslide.Shapes.PasteSpecial(DataType:=ppPasteMetafilePicture)
shp.Left = FromLeft
shp.Top = FromTop

所以你的代码的其余部分:
Sub AddChartToPPT(PPT As PowerPoint.Application, Slide As Integer, Chart As String, FromTop As Double, FromLeft As Double, Length As Double, Width As Double)
Dim activeslide As PowerPoint.Slide, shp as Object
PPT.ActiveWindow.View.GotoSlide Slide
Set activeslide = PPT.ActivePresentation.Slides(Slide)
ActiveSheet.ChartObjects(Chart).Activate
ActiveChart.ChartArea.Copy
set shp=activeslide.Shapes.PasteSpecial(DataType:=ppPasteMetafilePicture)
shp.Left = FromLeft
shp.Top = FromTop
'Need to add scaling code
End Sub

关于excel - 从excel(Excel VBA)插入后在PowerPoint中调整图表大小,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/12983768/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com