|
-
Jul 6th, 2012, 06:21 AM
#1
Thread Starter
Don't Panic!
[RESOLVED] Excel, (Shape) Label on sheet - caption changing
Hi,
How do I change the caption on a label that is on a sheet (not on a form) ?
I've tried:
shp <<< defined as a shape
Code:
For lngS = 1 To ActiveWorkbook.Sheets.Count
Set sht = ActiveWorkbook.Sheets(lngS)
On Error Resume Next
Set shp = sht.Shapes("lblLastMonth")
shp.Caption = "(May 2012)" 'errors
shp.TextFrame.Characters.Text = "(May 2012)" ' errors
On Error GoTo 0
Next
Any links or how to fix please? (I have the same label on multiple sheets, and want the code to flip through the sheets and change the caption on the label.
Recording a macro doesn't store (the property window must not be recorded).
Thanks in advance
Feeling like a fly on the inside of a closed window (Thunk!)
If I post a lot, it is because I am bored at work! ;D Or stuck...
* Anything I post can be only my opinion. Advice etc is up to you to persue...
-
Jul 6th, 2012, 05:52 PM
#2
Re: Excel, (Shape) Label on sheet - caption changing
the shape contains an oleobject that contains the lable
try like
vb Code:
shp.oleformat.object.object.caption = "(May 2012)"
i do my best to test code works before i post it, but sometimes am unable to do so for some reason, and usually say so if this is the case.
Note code snippets posted are just that and do not include error handling that is required in real world applications, but avoid On Error Resume Next
dim all variables as required as often i have done so elsewhere in my code but only posted the relevant part
come back and mark your original post as resolved if your problem is fixed
pete
-
Jul 9th, 2012, 06:38 AM
#3
Thread Starter
Don't Panic!
Re: Excel, (Shape) Label on sheet - caption changing
Feeling like a fly on the inside of a closed window (Thunk!)
If I post a lot, it is because I am bored at work! ;D Or stuck...
* Anything I post can be only my opinion. Advice etc is up to you to persue...
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|