excel - 尝试读取 Comment 属性时出现运行时错误 438
问题描述
在尝试获取评论的文本时(在检查评论是否存在之后)我得到
运行时错误 438“对象不支持此属性或方法”。
s = rR.Comment
该过程在遇到源工作表“v”中带有注释的第一个单元格时停止。
Dim i As Long, j As Long, c As Long
Dim w As Worksheet, v As Worksheet
Dim s As String
Dim rR As Range
Set w = ThisWorkbook.Sheets(1)
Set v = ThisWorkbook.Sheets(2)
For i = 1 To 10
For j = 1 To 10
For c = 0 To 12
s = ""
Set rR = w.Cells(i, c + 7)
With rR
.ClearContents
.ClearComments
.Interior.Pattern = xlNone
v.Cells(j, c + 4).Copy
.PasteSpecial Paste:=xlPasteValues
.PasteSpecial Paste:=xlPasteComments
Application.CutCopyMode = False
If Not .Comment Is Nothing Then
s = rR.Comment ' <============== ### HERE IT STOPS WITH RUN-TIME ERROR 438 ###
If InStr(1, s, "test") > 0 Then
.Interior.Pattern = xlSolid
.Interior.PatternColorIndex = xlAutomatic
.Interior.Color = 13434828
.Interior.TintAndShade = 0
.Interior.PatternTintAndShade = 0
End If
End If
End With
Set rR = Nothing
Next c
Next j
Next i
解决方案
我想你只是从头到尾都错过了.text
。
尝试:
s = rR.Comment.Text
推荐阅读
- hive - 如何以“。”分隔的字符串形式比较版本号?
- angular - 即使应用程序运行良好,NgRx Redux devtools 也没有显示存储和状态详细信息
- php - 如何仅返回在 Twig 模板、Rainlab.Translate 模块中具有翻译的文章
- javascript - 在 node.js 上使用 jqplot?
- java - OSGI 缓存目录
- c# - 实体框架 - 同时使用 FK 插入父模型和子模型
- c# - ASPX 页面有重复的行,即使它们在 SQL 中没有重复
- c++ - 将函数作为参数传递以避免重复代码
- oracle - APEX 5.1,在列链接中设置项目值不喜欢特殊字符...比如逗号或#
- python - 如何在 PyQt 中创建可折叠的盒子