|
-
Feb 10th, 2012, 04:09 PM
#1
Thread Starter
New Member
[RESOLVED] Excel Chart Textbox with Formula
I add a textbox in the lower right hand corner of a chart for supplemental information. This code snippet works:
Code:
Set tb = ActiveChart.Shapes.AddTextbox _
(msoTextOrientationHorizontal, _
ActiveChart.ChartArea.width - 125, _
ActiveChart.ChartArea.Height - 22, _
124, _
21)
With tb
.Fill.BackColor.RGB = RGB(225, 225, 225)
.TextFrame.HorizontalAlignment = xlHAlignCenter
.TextFrame.VerticalAlignment = xlVAlignCenter
End With 'textbox "frame"
tb.Select
Selection.Formula = "='peak detect'!$I$2"
where "peak detect" is my source page for the formula. Look at the last two lines. Why do I have to do this? For some reason I have to select the shape object to set the formula. I can't find any other way to set the formula property of a textbox.
Thank you
-
Feb 11th, 2012, 02:40 AM
#2
Re: Excel Chart Textbox with Formula
i do not believe that textboxes have a formula property, possibly like
vb Code:
With tb .Fill.BackColor.RGB = RGB(225, 225, 225) .TextFrame.HorizontalAlignment = xlHAlignCenter .TextFrame.VerticalAlignment = xlVAlignCenter .textfame.range.text = "='peak detect'!$I$2" End With
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
-
Feb 15th, 2012, 11:25 AM
#3
Thread Starter
New Member
Re: Excel Chart Textbox with Formula
Sorry,
That doesn't work.
-
Feb 15th, 2012, 05:38 PM
#4
Frenzied Member
Re: Excel Chart Textbox with Formula
what is the problem with your method?
here to think
-
Feb 15th, 2012, 07:01 PM
#5
Thread Starter
New Member
Re: Excel Chart Textbox with Formula
I'm just bamboozled that I have to "select" the textbox to assign it a formula. Why does the act of selecting suddenly give me access to the formula property?
-
Feb 16th, 2012, 04:57 AM
#6
Re: Excel Chart Textbox with Formula
try
vb Code:
tb.oleformat.object.formula = "='peak detect'!$I$2"
i tested this
Last edited by westconn1; Feb 16th, 2012 at 05:03 AM.
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
-
Feb 16th, 2012, 10:45 AM
#7
Thread Starter
New Member
Re: Excel Chart Textbox with Formula
westconn1,
Beautimus!
Thank you!
PS - how did you find this? I've been mucking through the object model for days with no luck ...
-
Feb 16th, 2012, 03:22 PM
#8
Re: [RESOLVED] Excel Chart Textbox with Formula
i checked in the locals window
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
-
Feb 16th, 2012, 03:44 PM
#9
Thread Starter
New Member
Re: [RESOLVED] Excel Chart Textbox with Formula
pete aka westconn1.
Thanks again!
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
|