代码之家  ›  专栏  ›  技术社区  ›  JeroenW

如何在VBA(PowerPoint)中检查随机幻灯片上文本框内的文本?

  •  0
  • JeroenW  · 技术社区  · 7 年前

    对于我正在做的演示,我想检查文本框中的文本(该文本框的名称为 文本框2 和是ActiveX控件)与另一个文本框中的文本相同(此文本框的名称为 纳姆 但不是ActiveX控件)。这是我现在拥有的代码:

    Dim osld As Slide
    Set osld = ActivePresentation.SlideShowWindow.View.Slide
    
    Dim vragen As Byte
    Dim juist As Byte
    Dim fout As Byte
    
    If osld.Shapes("TextBox2").TextFrame.TextRange = osld.Shapes("naam").TextFrame.TextRange Then
    osld.Shapes("TextBox2") = ""
    

    当我想运行这段代码时,我得到一个错误(找不到方法或数据成员)。

    如何使此代码正常工作?

    1 回复  |  直到 7 年前
        1
  •  1
  •   Steve Rindsberg    7 年前

    activepresentation。幻灯片(1)。形状(“文本框1”)。OLEFormat。对象文本

    而不是

    If osld.Shapes("TextBox2").TextFrame.TextRange = etc
    

    使用

    If osld.Shapes("TextBox2").OLEFormat.Object.Text = etc
    

    osld.Shapes("TextBox2").OLEFormat.Object.Text = ""