微信公众号搜"智元新知"关注
微信扫一扫可直接关注哦!

VBA运行时错误91,对象变量或未设置块变量

如何解决VBA运行时错误91,对象变量或未设置块变量

我正在尝试将数据从excel复制到ppt。下面是我的代码的一部分...我在下面提到的行上出错。问题是它大多数时间都在运行,但是突然开始抛出错误。请帮助我找出相同的原因

 Dim pptChart As Chart
    Dim pptChartData As ChartData
    Dim sld As Slide
    Dim shp As Shape
    Dim wbk,wbk_copy As Workbook
    Dim wbk_paste As Worksheet
    Dim filepath As String
    Dim date_string As String
    
    filepath = ActivePresentation.Path
    
    Dim xlApp As Object
    Set xlApp = CreateObject("Excel.Application")
    Set wbk_copy = xlApp.Workbooks.Open(filepath & "\development file.xlsm",True,False)
    'xlApp.Visible = True
    date_string = (wbk_copy.Worksheets("Data").Cells(10,2))
    existing_date_string = (wbk_copy.Worksheets("Data").Cells(11,2))
    wbk_copy.Close True
    Set xlApp = nothing   
    For Each shp In sld.Shapes
      If shp.Name = "Title1" Then

        '##### Getting error on below line ####
          m = shp.TextFrame.TextRange.Find(existing_date_string).Characters.Start 
                    shp.TextFrame.TextRange.Characters(m).InsertBefore (date_string)
                    shp.TextFrame.TextRange.Find(existing_date_string).Delete
      End If

版权声明:本文内容由互联网用户自发贡献,该文观点与技术仅代表作者本人。本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌侵权/违法违规的内容, 请发送邮件至 dio@foxmail.com 举报,一经查实,本站将立刻删除。