【问题标题】:Powerpoint syntax does not runPowerPoint 语法不运行
【发布时间】:2014-02-07 15:16:22
【问题描述】:

我有以下代码:

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

结束

结束子

我有两个问题

  1. 我尝试使用这个语句来安排字体大小

    .TextEffect.FontSize = 12

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

  1. 如果我现在运行它,我必须插入一个数字。但是那个数字并没有出现在文件中。我已经尝试将昏暗更改为

    将 var1 调暗为数字

我收到一个错误,即未定义用户定义的类型。有人知道这里出了什么问题吗?

【问题讨论】:

    标签: vba powerpoint


    【解决方案1】:

    改用这个:

    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 或其他数字类型;否则,作为字符串

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 2011-03-05
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2012-01-13
      • 1970-01-01
      • 2016-02-16
      • 2016-11-29
      相关资源
      最近更新 更多