excel - 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
解决方案
推荐阅读
- matlab - 如何在 MatLab Appdesigner 的 parforloop 下运行 NamedPipe 流
- asp.net - 如何在RouteConfig asp.net mvc中搜索没有action关键字
- javascript - TensorFlow JS - 加载使用 Python 生成的模型
- sql - 如何选择已借阅所有书籍的会员
- reactjs - 显示加载器直到页面完全加载反应
- python - Docker X11 Forward 得到黑屏
- java - Java JNI 错误 java.lang.UnsupportedClassVersionError
- javascript - 使用 nodejs/npm start 在哪里查看 console.log 输出?
- android - React Native Metro 捆绑器不会自动启动仅适用于 android
- sql-server - Entity Framework .Database.Initialize(true) 在 Azure 上工作时不创建表