macro runs fine but error message is displayed

A

already

Hello

I have the following problem. My macro runs fine but I receive the following
error message ' System Error &H80004005 (-2147467259). Unspecified error '

How can I get rid of this message

Kind regards

Al
 
R

Rick Rothstein

Given what you have posted, my best guess would be to remove the offending
line of code.<g> Perhaps if you showed us your code, and maybe give us a
short description of what it is doing, then maybe we could narrow down our
recommendation a little bit for you.
 
A

already

Oeps sorry boys
This is the code with an error handler for hiding the error message

Sub testme()
Dim Shp As Shape
Dim InitialShape As Boolean

On Error GoTo ErrHandler:

InitialShape = True
For Each Shp In ActiveSheet.Shapes
If Shp.Name = Range("N1").Value Then '
'skip it
Else
Shp.Select Replace:=InitialShape
InitialShape = False
End If
Next Shp
ErrHandler: Exit Sub

End Sub

Kind regards

Al
 
R

Rick Rothstein

I did a quick test of your code and it did not generate any errors; however,
that may be because you have other objects that are affecting the code in
some way. However, I do note that you have InitialShape declared as a
Boolean and are using it as the assignment value to the Replace argument of
the shape's Select method... the help files say that the Replace object
takes an Object, not a Boolean, so that may have something to do with your
problem (I have not used the Replace argument with a shape's Select method
before, so I'm not entirely clear what is supposed to be replaced here). I
also note that your Error Handler simply executes an Exit Sub statement...
given that, you don't really need it... jumping to the error handler's label
will execute the following statement so if there is nothing following that
label, the End Sub is executed and the macro ends at that point.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top