[英]Run-Time error '1004' The specified value is out of range
Sub FindInShapes1()
Dim rStart As Range
Dim shp As Shape
Dim sFind As String
Dim sTemp As String
Dim Response
sFind = InputBox("Search for?")
If Trim(sFind) = "" Then
MsgBox "Nothing entered"
Exit Sub
End If
Set rStart = ActiveCell
For Each shp In ActiveSheet.Shapes
sTemp = shp.TextFrame.Characters.Text
If InStr(LCase(sTemp), LCase(sFind)) <> 0 Then
shp.Select
Response = MsgBox( _
prompt:=shp.TopLeftCell & vbCrLf & _
sTemp & vbCrLf & vbCrLf & _
"Do you want to continue?", _
Buttons:=vbYesNo, Title:="Continue?")
If Response <> vbYes Then
Set rStart = Nothing
Exit Sub
End If
End If
Next
MsgBox "No more found"
rStart.Select
Set rStart = Nothing
End Sub
Hi, 嗨,
I made the above Macro for finding excel shapes in a "crouded" worksheet, by the text written inside. 我编写了上面的Macro,以便在其中写的文本中找到“经过欺骗的”工作表中的excel形状。 The macro works in any new books but not in the one I need, were it keeps on showing the following message:
如果它继续显示以下消息,则该宏可用于任何新书,但不适用于我需要的书:
"Run-Time error '1004'
The specified value is out of range"
and as soon as i click on "Debug" it highlights the line: 当我单击“调试”时,它将突出显示以下行:
sTemp = shp.TextFrame.Characters.Text
What's wrong? 怎么了?
Thanks for your help Chiara 感谢您的帮助Chiara
There is nothing wrong with your code. 您的代码没有错。 You will only get this error if the Active worksheet is password protected.
如果活动工作表受密码保护,则只会出现此错误。
Can you check that? 你能检查一下吗?
Also check below url from so 另外从下面检查网址
I think as there is no way to check for the existence of a TextFrame within a shape, you should ignore the error by using On Error Resume Next : 我认为由于无法检查形状中是否存在TextFrame ,因此应使用On Error Resume Next忽略该错误:
Sub FindInShapes1()
Dim rStart As Range
Dim shp As Shape
Dim sFind As String
Dim sTemp As String
Dim Response
On Error Resume Next
sFind = InputBox("Search for?")
If Trim(sFind) = "" Then
MsgBox "Nothing entered"
Exit Sub
End If
Set rStart = ActiveCell
For Each shp In ActiveSheet.Shapes
'If shp.TextFrame.Characters.Count > 0 Then
If InStr(LCase(sTemp), LCase(sFind)) <> 0 Then
shp.Select
Response = MsgBox( _
prompt:=shp.TopLeftCell & vbCrLf & _
sTemp & vbCrLf & vbCrLf & _
"Do you want to continue?", _
Buttons:=vbYesNo, Title:="Continue?")
If Response <> vbYes Then
Set rStart = Nothing
Exit Sub
End If
End If
'End If
sTemp = shp.TextFrame.Characters.Text
Next
MsgBox "No more found"
rStart.Select
Set rStart = Nothing
End Sub
` `
Sorry to break the convention but the similar error I get: 抱歉违反约定,但我得到类似的错误:
The specified value is out of range
Run-time error -2147024809
In my scenario I am simply returning a shape as part of a GET property in side a class that store a Shape Object. 在我的场景中,我只是在存储Shape对象的类中将形状作为GET属性的一部分返回。 The property works for Shape Type Text Boxes but craps out on sending back Line Shapes.
该属性适用于“形状类型”文本框,但在发送回“线形”时会刮擦。 As per below.
如下所示。 I cannot use the on error, Or don't know how because the error occur at End Property?
我无法使用on错误,或者因为错误发生在End Property而不知道怎么办?
Public Property Get shp_Obj() As Shape
If prvt_int_Ordinal = 13 Them
MsgBox prvt_Shp_Shape.Name, , "prvt_Shp_Shape.Name"
Set shp_Obj = prvt_Shp_Shape
End If
End Property
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.