VBA粘贴Excel活动工作表中的每一嵌入式图表到一个新的幻灯片中并使用图表标题作为幻灯片标题

VBA粘贴Excel活动工作表中的每一嵌入式图表到一个新的幻灯片中并使用图表标题作为幻灯片标题,第1张

概述VBA粘贴Excel活动工作表中的每一嵌入式图表到一个新的幻灯片中并使用图表标题作为幻灯片标题

下面是内存溢出 jb51.cc 通过网络收集整理的代码片段。

内存溢出小编现在分享给大家,也给大家做个参考。

Sub ChartsAndTitlestopresentation()' Set a VBE reference to Microsoft PowerPoint Object libraryDim PPApp As PowerPoint.ApplicationDim PPPres As PowerPoint.PresentationDim PPSlIDe As PowerPoint.SlIDeDim Presentationfilename As VariantDim SlIDeCount As LongDim iCht As IntegerDim sTitle As String' Reference existing instance of PowerPointSet PPApp = Getobject(,"Powerpoint.Application")' Reference active presentationSet PPPres = PPApp.ActivePresentationPPApp.ActiveWindow.VIEwType = ppVIEwSlIDeFor iCht = 1 To ActiveSheet.ChartObjects.Count    With ActiveSheet.ChartObjects(iCht).Chart                ' get chart Title        If .HasTitle Then            sTitle = .ChartTitle.Text        Else            sTitle = ""        End If                ' remove Title (or it will be redundant)        .HasTitle = False                ' copy chart as a picture        .copyPicture _            Appearance:=xlScreen,Size:=xlScreen,Format:=xlPicture                ' restore Title        If Len(sTitle) > 0 Then            .HasTitle = True            .ChartTitle.Text = sTitle        End If    End With        ' Add a new slIDe and paste in the chart    SlIDeCount = PPPres.SlIDes.Count    Set PPSlIDe = PPPres.SlIDes.Add(SlIDeCount + 1,ppLayoutTitleOnly)    PPApp.ActiveWindow.VIEw.GotoSlIDe PPSlIDe.SlIDeIndex    With PPSlIDe        ' paste and select the chart picture        .Shapes.Paste.Select        ' align the chart        PPApp.ActiveWindow.Selection.ShapeRange.Align msoAlignCenters,True        PPApp.ActiveWindow.Selection.ShapeRange.Align msoAlignmIDdles,True        .Shapes.Placeholders(1).TextFrame.TextRange.Text = sTitle    End WithNext' Clean upSet PPSlIDe = nothingSet PPPres = nothingSet PPApp = nothingEnd Sub

以上是内存溢出(jb51.cc)为你收集整理的全部代码内容,希望文章能够帮你解决所遇到的程序开发问题。

如果觉得内存溢出网站内容还不错,欢迎将内存溢出网站推荐给程序员好友。

总结

以上是内存溢出为你收集整理的VBA粘贴Excel活动工作表中的每一嵌入式图表到一个新的幻灯片中并使用图表标题作为幻灯片标题全部内容,希望文章能够帮你解决VBA粘贴Excel活动工作表中的每一嵌入式图表到一个新的幻灯片中并使用图表标题作为幻灯片标题所遇到的程序开发问题。

如果觉得内存溢出网站内容还不错,欢迎将内存溢出网站推荐给程序员好友。

欢迎分享,转载请注明来源:内存溢出

原文地址: https://www.outofmemory.cn/langs/1274815.html

(0)
打赏 微信扫一扫 微信扫一扫 支付宝扫一扫 支付宝扫一扫
上一篇 2022-06-08
下一篇 2022-06-08

发表评论

登录后才能评论

评论列表(0条)

保存