Powerpoint语法不运行

时间:2014-02-07 15:16:23

标签: vba powerpoint-vba

我有以下代码:

Sub ppt()

Dim pptapp As PowerPoint.Application
Dim ppt As PowerPoint.Presentation
Dim slide As PowerPoint.slide
Dim shape As PowerPoint.shape

Dim var1 As String

Set pptapp = CreateObject("Powerpoint.Application")
pptapp.Visible = True

Set ppt = pptapp.Presentations.Open("X:\SSC_HR\SENS\Bedrijfsbureau\Rapportages\SENS      referenten rapportage\Nieuwe ref rap template\SENS referent rapportage januari 2014.pot")
Set slide = ppt.Slides(1)
Set shape = slide.Shapes.AddTextbox(msoTextOrientationHorizontal, 100, 500, 100, 100)

var = InputBox("Insert weeknumber")

With shape

.TextFrame.TextRange = "Update call Jeroen van Breda Vriesman/Ton van der Linden" & vbNewLine & var1 & vbNewLine & "Tel nr: +31 (0)10 - 299 1002  code 59790989 "
.Line.Visible = True
.Width = 200
.Height = 200
.TextEffect.FontSize = 12

End With

With ppt
.SaveAs "C:\Documents and Settings\aa471714\Desktop\" & "SENS referentenrapporge - week" & var1
.Close

结束

End Sub

我有两个问题

  1. 我尝试使用此声明排列字体大小

    .TextEffect.FontSize = 12

  2. 但这不起作用。任何人都知道这里出了什么问题。如果我在没有这条线的情况下运行它一切顺利。

    1. 如果我现在运行它,我必须插入一个数字。但那个数字不会出现在文件中。我已经尝试将昏暗变为

      Dim var1 As Number

    2. 我收到一条未定义用户定义类型的错误。有谁知道这里出了什么问题?

1 个答案:

答案 0 :(得分:0)

相反,请使用:

With shape

.TextFrame.TextRange = "Update call Jeroen van Breda Vriesman/Ton van der Linden" & vbNewLine & var1 & vbNewLine & "Tel nr: +31 (0)10 - 299 1002  code 59790989 "
.Line.Visible = True
.Width = 200
.Height = 200
.TextFrame.TextRange.Font.Size = 12

End With

你想要做

如果要保存数字,请将var1变为Long或其他数字类型;否则,如String