使用默认的SlideMaster在Excel中创建Power Point演示文稿

时间:2016-05-31 08:32:59

标签: vba excel-vba powerpoint-vba excel

我正在构建一个获取Excel数据并放入PowerPoint演示文稿的宏,但是我的宏从头开始创建的演示文稿包含默认的Office SlideMaster,而不是通过手动打开PowerPoint创建的新演示文稿,其中包含从中加载的SlideMaster C:\ Users \ xxxx \ AppData \ Roaming \ Microsoft \ Windows \ Templates \ blank.potx这是一个公司的slidemaster。我希望宏用公司slidemaster创建一个演示文稿,问题是宏将在不同的计算机上运行,​​因此我不能使用blank.potx的路径(用户名更改)。

是否有可能以这种方式工作?

这是我的代码的开始:

Sub mainsub()

Dim PowerPointApp As Object
Dim myPresentation As Object
Dim mySlide As Object
Dim mySlide2 As Object
Dim myShape As Object
Dim myShape1 As Object
Dim myShape2 As Object
Dim ws As Worksheet

Set formularz = ThisWorkbook.Sheets("formularz")

On Error Resume Next

Set PowerPointApp = GetObject(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 = False

Set myPresentation = PowerPointApp.Presentations.Add

Set mySlide = myPresentation.Slides.Add(1, 12)

With myPresentation.PageSetup
.SlideWidth = 800
.SlideHeight = 450
End With

ThisWorkbook.Sheets("formularz").Activate

PowerPointApp.Visible = True
PowerPointApp.Activate
PowerPointApp.WindowState = 2

mySlide.Select
Set myShape1 = mySlide.Shapes.addTextbox(msoTextOrientationHorizontal, 100, 100, 100, 100)

    text1 = formularz.Range("B2").text
    myShape1.TextFrame.TextRange.text = text1
    myShape1.top = 0
    myShape1.TextFrame.TextRange.Font.Name = "Helvetica 75"
    myShape1.TextFrame.TextRange.Font.Color.RGB = RGB(255, 102, 0)
    myShape1.TextFrame.WordWrap = 0
    myShape1.left = 400 - myShape1.width / 2

PowerPointApp.ActiveWindow.Selection.Unselect

。 。

等等,主要是创造了大量的其他幻灯片和形状。 可能我的问题的答案是(将被放置)在上面的代码中。

感谢任何建议

0 个答案:

没有答案
相关问题