PC Review


Reply
Thread Tools Rate Thread

button name scope and Caption

 
 
cate
Guest
Posts: n/a
 
      3rd Apr 2010
I have a main sheet that I replicate as 'what if' versions. There are
no collisions with any names on these copies since all code refers to
them in the context of the sheet.

Except for buttons and their attribute Caption.

There is one these buttons that has it's caption changed ('Show',
'Hide') but even within the context of the current sheet, it fails.

wS.Buttons("button_show_hide").Caption = "Hide"

What is REALLY strange is that the caption seems to be changing
somewhere, because the decision to Show or Hide is based on the
following. Again, this is successful:

StrComp(wS.Buttons("button_show_hide").Caption, "Hide")

The main sheet, from which all these 'What if's are copied, it's
button continues to work just fine. The caption toggles.

Anyone have an idea how to fix this?
 
Reply With Quote
 
 
 
 
Dave Peterson
Guest
Posts: n/a
 
      3rd Apr 2010
Maybe your current sheet isn't what you expect. You didn't share how ws was
set.

This may help (or not!) you debug...

Option Explicit
Sub testme()

Dim ws As Worksheet
Dim BTN As Button

Set ws = Worksheets("SomeSheetNameHere")

For Each BTN In ws.Buttons
With BTN
MsgBox .Name & vbLf _
& .TopLeftCell.Address & vbLf _
& .Visible
End With
Next BTN

End Sub

You may even want to loop through the worksheets in the workbook, too:

Option Explicit
Sub testme2()

Dim ws As Worksheet
Dim BTN As Button

For Each ws In ActiveWorkbook.Worksheets
For Each BTN In ws.Buttons
With BTN
MsgBox .Parent.Name & vbLf _
& .Name & vbLf _
& .TopLeftCell.Address & vbLf _
& .Visible
End With
Next BTN
Next ws

End Sub

cate wrote:
>
> I have a main sheet that I replicate as 'what if' versions. There are
> no collisions with any names on these copies since all code refers to
> them in the context of the sheet.
>
> Except for buttons and their attribute Caption.
>
> There is one these buttons that has it's caption changed ('Show',
> 'Hide') but even within the context of the current sheet, it fails.
>
> wS.Buttons("button_show_hide").Caption = "Hide"
>
> What is REALLY strange is that the caption seems to be changing
> somewhere, because the decision to Show or Hide is based on the
> following. Again, this is successful:
>
> StrComp(wS.Buttons("button_show_hide").Caption, "Hide")
>
> The main sheet, from which all these 'What if's are copied, it's
> button continues to work just fine. The caption toggles.
>
> Anyone have an idea how to fix this?


--

Dave Peterson
 
Reply With Quote
 
cate
Guest
Posts: n/a
 
      3rd Apr 2010
A close and open the wb did the trick. I guess even with -->edit --
>move or copy sheet


some things are not completed.

Thanks
 
Reply With Quote
 
 
 
Reply

Thread Tools
Rate This Thread
Rate This Thread:

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
Button Caption help Jim Brooks Microsoft Access Getting Started 3 6th Feb 2010 12:18 PM
Where did the Change Scope button go? Kan Windows Vista Networking 0 24th Jul 2006 03:18 PM
Created custom caption bar - need help with caption button positio =?Utf-8?B?TWFyaXVzSQ==?= Microsoft Dot NET Framework Forms 0 28th Jun 2005 08:21 AM
ADSI returning groups in Global scope and Domain local scope instead of Universal scope Maziar Aflatoun Microsoft C# .NET 1 21st Apr 2004 04:08 PM
Custom Button Scope Limitation =?Utf-8?B?Um9uRg==?= Microsoft Excel Programming 1 27th Feb 2004 02:43 PM


Features
 

Advertising
 

Newsgroups
 


All times are GMT +1. The time now is 01:44 PM.