因此,我需要每个月制作一个PowerPoint演示文稿,其中包括将大约25个命名范围从excel复制到单独的幻灯片中,然后为它们提供相应的标题。虽然我相信我已经破解了复制和粘贴部分,但我只能通过在VBA中实际命名它来命名标题理想情况下我想从excel中的单元格中获取标题,但主要是我希望能够格式化标题例如,字体代码返回时的大小,颜色和字体 “对象不支持此属性或方法”。
Sub CreatePresentation()
Dim rng As Range
Dim PowerPointApp As PowerPoint.Application
Dim myPresentation As PowerPoint.Presentation
Dim mySlide As PowerPoint.Slide
Dim myShape As PowerPoint.Shape
Dim myTitle As Variant
Set rng = Range("PL_Tot")
On Error Resume Next
Set PowerPointApp = CreateObject(class:="PowerPoint.Application")
Err.Clear
If PowerPointApp Is Nothing Then Set PowerPointApp = CreateObject(class:="PowerPoint.Application")
If Err.Number = 429 Then
MsgBox "PowerPoint could not be found, aborting."
Exit Sub
End If
On Error GoTo 0
Application.ScreenUpdating = True
Set myPresentation = PowerPointApp.Presentations.Add
Set mySlide = myPresentation.Slides.Add(1, 11) '11 = ppLayoutTitleOnly
rng.Copy
mySlide.Shapes.PasteSpecial DataType:=xlBitmap
Set myShape = mySlide.Shapes(mySlide.Shapes.Count)
myShape.Left = 0.3
myShape.Top = 67
myShape.Width = 430
myShape.Height = 406.4
mySlide.Shapes.Title.TextFrame.TextRange.Text = "Total Physical & Digital P&L – GamesInput16"
mySlide.Shapes.Title.TextFrame.TextRange.Font = "Arial (Headings)"
PowerPointApp.Visible = True
PowerPointApp.Activate
Application.CutCopyMode = False
Set rng = Range("PL_Phys")
这是第一张幻灯片的代码,然后代码重复下一张幻灯片,等等。
非常感谢任何帮助,谢谢!