开发者

How to use the Font.Underline property of an Excel 2007 chart element

I'm trying to write some VBA code to copy the font style of one chart element to another in an Excel 2007 chart. Specifically, I'm trying to copy the font style from t开发者_开发知识库he ChartArea to the ChartTitle. I'm having a problem with the Font.Underline property.

No matter what the Underline property of the ChartArea is set to (e.q. xlUnderlineStyleSingle), the Underline property returns a value that does not match any of the XlUnderlineStyle constants (the value is 1745390344).

This is no doubt related to the fact that the UI for setting the font of a chart element is slightly different from the UI for setting the font of a cell on a worksheet.

For a cell, the UI shows only two underline styles (single & double) plus "none". This corresponds to the values in the XlUnderlineStyle enumeration.

For a chart element, the UI shows a whole bunch of underline styles including wavy lines etc. These are not represented in that enumeration.

So, I suspect that - for chart elements - there is actually another property that can be set, and the Font.Underline property is simply returning a "look elsewhere" value.

Can anyone tell me what that other property is called, and whether I can access that through VBA?


EDIT here's some code you can type directly into the immediate window to see the problem (select a chart first):

? ActiveChart.ChartArea.Font.Underline


The msoTextUnderlineType enum is used in the ChartArea.Format.Textframe2.TextRange.Font.Underlinestyle property.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜