![]() |
Problem setting Charttitle in VB
Hi,
Our client requested a chart with a title longer than 255. Is there a work-around? Thanks! Faith Code sample: Dim xlCH As Excel.Chart xlCH.HasTitle = true xlCH.ChartTitle.Text = "some character string longer than 255..." |
Problem setting Charttitle in VB
faith wrote:
Hi, Our client requested a chart with a title longer than 255. Is there a work-around? Thanks! Faith Code sample: Dim xlCH As Excel.Chart xlCH.HasTitle = true xlCH.ChartTitle.Text = "some character string longer than 255..." Reference a range rather than hard-code the text. |
Problem setting Charttitle in VB
"David Welch" wrote in message ... faith wrote: Hi, Our client requested a chart with a title longer than 255. Is there a work-around? Thanks! Faith Code sample: Dim xlCH As Excel.Chart xlCH.HasTitle = true xlCH.ChartTitle.Text = "some character string longer than 255..." Reference a range rather than hard-code the text. I don't think that's possible, either with code or manually by selecting the title, then in the input bar enter =A1. Whatever text in the cell over 255 gets truncated to 255- But I might be wrong ? Could insert a textbox from the drawing toolbar into the chart, then paste long text. The copy source would need to be text, say copied from the input bar, rather than a cell. With code, would need to insert characters into the textframe in chunks of less than 255 at a time. Regards, Peter T |
Problem setting Charttitle in VB
Peter T wrote:
"David Welch" wrote in message ... faith wrote: Hi, Our client requested a chart with a title longer than 255. Is there a work-around? Thanks! Faith Code sample: Dim xlCH As Excel.Chart xlCH.HasTitle = true xlCH.ChartTitle.Text = "some character string longer than 255..." Reference a range rather than hard-code the text. I don't think that's possible, either with code or manually by selecting the title, then in the input bar enter =A1. Whatever text in the cell over 255 gets truncated to 255- But I might be wrong ? Could insert a textbox from the drawing toolbar into the chart, then paste long text. The copy source would need to be text, say copied from the input bar, rather than a cell. With code, would need to insert characters into the textframe in chunks of less than 255 at a time. Regards, Peter T Bah-Humbug, you are right :-) I did a test and thought it worked but actually it didn't. |
Problem setting Charttitle in VB
Peter,
Thanks for the insight. Could you please give me some code sample as to how to .... then paste long text. The copy source would need to be text, say copied from the inputbar, rather than a cell. With code, would need to insert characters into the textframe in chunks of less than 255 at a time. Again, thanks for your help! Faith Peter T wrote: "David Welch" wrote in message ... faith wrote: Hi, Our client requested a chart with a title longer than 255. Is there a work-around? Thanks! Faith Code sample: Dim xlCH As Excel.Chart xlCH.HasTitle = true xlCH.ChartTitle.Text = "some character string longer than 255..." Reference a range rather than hard-code the text. I don't think that's possible, either with code or manually by selecting the title, then in the input bar enter =A1. Whatever text in the cell over 255 gets truncated to 255- But I might be wrong ? Could insert a textbox from the drawing toolbar into the chart, then paste long text. The copy source would need to be text, say copied from the input bar, rather than a cell. With code, would need to insert characters into the textframe in chunks of less than 255 at a time. Regards, Peter T |
Problem setting Charttitle in VB
Hi Faith,
This adds a new sheet, makes formula and similar value cells with long text, adds a chart sheet and textbox named MyTitle", puts 840 charactes into the textbox - Sub test() Dim sText$, sPart$ Dim j as long Dim ws As Worksheet Dim cht As Chart, shp As Shape Set ws = ActiveWorkbook.Worksheets.Add [b2].Formula = "=REPT(""x"",37) & ""40 """ [b3].Formula = "=b1&b2" [b3].AutoFill [b3:b9] [b12:b19].Value = [b3:b9].Value [a3].Formula = "=len(b3)" [a3].AutoFill [a3:a18] sText = [b9].Text 'len 840 MsgBox "sText " & Len(sText) Set cht = ThisWorkbook.Charts.Add Set shp = cht.Shapes.AddTextbox(1, 99#, 9#, 540#, 210#) With shp .Name = "MyTitle" .Line.Visible = msoTrue j = 1 Do While j < Len(sText) sPart$ = VBA.Strings.Mid(sText, j, 250) .TextFrame.Characters(j).Insert String:=sPart$ j = j + 250 Loop End With ' or say ActiveSheet.Worksheet.ChartObjects(1) has a textbox named "MyTitle" 'Set shp = ActiveSheet.ChartObjects(1).Chart.Shapes("MyTitle" ) End Sub With b18, 840 characters, in the edit bar I selected and copied the text, then could paste into a textbox. But I couldn't simply copy the cell and paste into a textbox. I didn't try typing +255 into the textbox. I expect you will need to play around with sizing, font etc. Look at font format autoscale. Regards, Peter T "faith" wrote in message oups.com... Peter, Thanks for the insight. Could you please give me some code sample as to how to ... then paste long text. The copy source would need to be text, say copied from the inputbar, rather than a cell. With code, would need to insert characters into the textframe in chunks of less than 255 at a time. Again, thanks for your help! Faith Peter T wrote: "David Welch" wrote in message ... faith wrote: Hi, Our client requested a chart with a title longer than 255. Is there a work-around? Thanks! Faith Code sample: Dim xlCH As Excel.Chart xlCH.HasTitle = true xlCH.ChartTitle.Text = "some character string longer than 255..." Reference a range rather than hard-code the text. I don't think that's possible, either with code or manually by selecting the title, then in the input bar enter =A1. Whatever text in the cell over 255 gets truncated to 255- But I might be wrong ? Could insert a textbox from the drawing toolbar into the chart, then paste long text. The copy source would need to be text, say copied from the input bar, rather than a cell. With code, would need to insert characters into the textframe in chunks of less than 255 at a time. Regards, Peter T |
All times are GMT +1. The time now is 06:54 AM. |
Powered by vBulletin® Copyright ©2000 - 2025, Jelsoft Enterprises Ltd.
ExcelBanter.com