why it does not work????

  • Thread starter Thread starter Guest
  • Start date Start date
G

Guest

can someone help me in this problem, I have the follow routine that does not
work:
For Each msheet In Worksheets
If Left(msheet.Name, 6) = "Player" Then
msheet.Unprotect Password:="xxx"

For Each mshape In msheet.Shapes
' I have a CommandButton
If mshape.Caption = "Played" Then <--- here it stops
running!!!
mshape.Caption = "Play"
mshape.BackColor = 16744576
End If
......
......
 
Every type of shape does not have a caption. So maybe...

On Error GoTo NextShape
For Each mshape In msheet.Shapes
If mshape.Caption = "Played" Then
mshape.Caption = "Play"
mshape.BackColor = 16744576
End If
NextShape:
Next
On Error GoTo 0

--
Jim
| can someone help me in this problem, I have the follow routine that does
not
| work:
| For Each msheet In Worksheets
| If Left(msheet.Name, 6) = "Player" Then
| msheet.Unprotect Password:="xxx"
|
| For Each mshape In msheet.Shapes
| ' I have a CommandButton
| If mshape.Caption = "Played" Then <--- here it stops
| running!!!
| mshape.Caption = "Play"
| mshape.BackColor = 16744576
| End If
| .....
| .....
| --
| tanks a lot
| Peres
 
Try the ALternativeText property not Caption

--
HTH

Bob

(there's no email, no snail mail, but somewhere should be gmail in my addy)
 
Tanks Jim but it does not work because the shape is a CommandButton and it
have a caption.
Tanks anyway.
 
tanks Bob but ALternativeText returns "" and not the Caption... I have no
idea about this problem.. but thanks anyway...
--
Peres


"Bob Phillips" escreveu:
Try the ALternativeText property not Caption

--
HTH

Bob

(there's no email, no snail mail, but somewhere should be gmail in my addy)
 
Which toolbar did you get the button from?

--
HTH

Bob

(there's no email, no snail mail, but somewhere should be gmail in my addy)

Peres said:
tanks Bob but ALternativeText returns "" and not the Caption... I have no
idea about this problem.. but thanks anyway...
 
This is difficult to say because the name of the bars is not written in
English - but in a free translation it would be Controls ( not Forms ). Does
it help??
 
Maybe, see if this works for you

Dim OLEobj As OLEObject

For Each mSheet In Worksheets
If Left(mSheet.Name, 6) = "Player" Then
mSheet.Unprotect Password:="xxx"

For Each OLEobj In ActiveSheet.OLEObjects
If OLEobj.Object.Caption = "Played" Then
OLEobj.Object.Caption = "Play"
OLEobj.Object.BackColor = 16744576
End If
Next OLEobj
End If
Next mSheet


--
HTH

Bob

(there's no email, no snail mail, but somewhere should be gmail in my addy)
 

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

Back
Top