gpt4 book ai didi

excel - 如何通过 VBA 使用我的 powerpoint 模板来构建我想要的幻灯片?

转载 作者:行者123 更新时间:2023-12-04 20:27:42 25 4
gpt4 key购买 nike

我不知道如何将我的模板合并到我在 VBA 中的实际代码中,以便我的工作表将构建在所需的模板和幻灯片中。

我已经在一个新的空白 powerpoint 幻灯片中构建了幻灯片,但还不知道如何使用模板来完成。

Sub LCTAKT_Macro()
'Declare variables
Dim PP As PowerPoint.Application
Dim PPPres As PowerPoint.Presentation
Dim PPSlide1 As PowerPoint.Slide
Dim PPSlide2 As PowerPoint.Slide
Dim PPSlide3 As PowerPoint.Slide
Dim PPSlide4 As PowerPoint.Slide
Dim PPSlide5 As PowerPoint.Slide
Dim PPSlide6 As PowerPoint.Slide
Dim PPSlide7 As PowerPoint.Slide
Dim SlideTitle As String
Dim objPPT As Object

'Open PowerPoint and create new presentation
Set objPPT = CreateObject("PowerPoint.Application")
objPPT.Visible = True

Set PP = New PowerPoint.Application
Set PPPres = PP.Presentations.Add
PP.Visible = True

objPPT.Presentations.Open ""

'-------------------------------------------------Station 42--------- ------------------------------------------------
'Add new slide as slide 2 and set focus to it
Set PPSlide1 = PPPres.Slides.Add(1, ppLayoutTitleOnly)
PPSlide1.Select

'Copy the range as a picture
Sheets("").Range("A1:W59").CopyPicture _
Appearance:=xlScreen, Format:=xlPicture

'Paste the picture and adjust its position
PPSlide1.Shapes.Paste.Select
PP.ActiveWindow.Selection.ShapeRange.Align msoAlignCenters, True
PP.ActiveWindow.Selection.ShapeRange.Align msoAlignMiddles, True

'Add the title to the slide
SlideTitle = ""
PPSlide1.Shapes.Title.TextFrame.TextRange.Text = SlideTitle

'Position pasted chart
PP.ActiveWindow.Selection.ShapeRange.Left = 200
PP.ActiveWindow.Selection.ShapeRange.Top = 130
PP.ActiveWindow.Selection.ShapeRange.Height = 523
PP.ActiveWindow.Selection.ShapeRange.Width = 554

我希望将模板合并到幻灯片中,同时仍为其构建必要的数据片段。

最佳答案

假设 Office 2013 或更高版本,请尝试以下操作:

TemplateName$ = "C:\Users\YourActualUserName\Documents\Custom Office Templates\YourActualTemplateName.potx"
Set PPPres = PP.Presentations.Open(TemplateName$, False, True, True)

关于excel - 如何通过 VBA 使用我的 powerpoint 模板来构建我想要的幻灯片?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/56841510/

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