Vba 使用chart.chartstyle=248时,如何关闭轴标题中的所有封口? 问题
我希望能够有效地取消选中excel图表轴标签/标题上VBA中所有大写字母的复选框Vba 使用chart.chartstyle=248时,如何关闭轴标题中的所有封口? 问题,vba,excel,charts,fonts,axes,Vba,Excel,Charts,Fonts,Axes,我希望能够有效地取消选中excel图表轴标签/标题上VBA中所有大写字母的复选框 我试过的 对于excel,图表中似乎没有将所有大写字母作为字符或字体成员的选项 此外,仅使用Upper、Ucase或LCase之类的工具更改文本是行不通的 一些代码 我在构建图表的地方包含了我的代码。您可以在注释中看到我更改allcaps属性的一些尝试。在excel中使用vba与以下类似: With newChart 'If put an if statement to see if name alr
我试过的 对于excel,图表中似乎没有将所有大写字母作为字符或字体成员的选项 此外,仅使用Upper、Ucase或LCase之类的工具更改文本是行不通的
一些代码 我在构建图表的地方包含了我的代码。您可以在注释中看到我更改allcaps属性的一些尝试。在excel中使用vba与以下类似:
With newChart
'If put an if statement to see if name already exists, try catch case would be good too
.Name = UsrFrm2.titleTxt.Text
.ChartType = xlXYScatterSmoothNoMarkers
'.CategoryLabelLevel = xlCategoryLabelLevelCustom
'using preselected formatting for chart
.ChartStyle = 248
.ChartColor = 10
'Labeling
.HasTitle = True
.ChartTitle.Text = Me.titleTxt.Text
.HasAxis(xlCategory, xlPrimary) = True
.HasAxis(xlCategory, xlSecondary) = True
.HasAxis(xlValue, xlPrimary) = True
.HasAxis(xlValue, xlSecondary) = True
.Axes(xlCategory, xlPrimary).CategoryType = xlAutomatic
'.Axes(xlCategory, xlSecondary).CategoryType = xlAutomatic
.Axes(xlCategory, xlPrimary).HasTitle = True
'.Axes(xlCategory, xlSecondary).HasTitle = True
'.Axes(xlValue, xlSecondary).AxisTitle.Characters.Text = "Loss Tangent (tand)"
.HasLegend = True
'.Axes(xlCategory, xlPrimary).MinimumScale = 1000000
' .Axes(xlCategory, xlPrimary).MaxiumScale = 1800000000
End With
或者像这样的事情:
With newChart
'trying to change the axis titles to turn off all caps. I cannot figure out how at the moment, will have to do by hand.
'Plotyy format
.Axes(xlCategory, xlPrimary).AxisTitle.Characters.Text = UsrFrm2.XALabel.Value
'.Axes(xlCategory, xlPrimary).AxisTitle.Characters.Font.Bold = False
.Axes(xlCategory, xlPrimary).AxisTitle.Characters.Font.FontStyle = "Normal"
'.Axes(xlCategory, xlPrimary).AxisTitle.Characters.Font.Allcaps = False
'.Axes(xlCategory, xlPrimary).AxisTitle.Font.Allcaps = False
.Axes(xlCategory, xlPrimary).MinimumScale = UsrFrm2.XSMin.Value
.Axes(xlCategory, xlPrimary).MaximumScale = UsrFrm2.XSMax.Value
.Axes(xlCategory, xlPrimary).MajorUnitIsAuto = True
.Axes(xlCategory, xlPrimary).MinorUnitIsAuto = True
If Me.X_MHz.Value = True Then
.Axes(xlCategory, xlPrimary).DisplayUnit = xlCustom
.Axes(xlCategory, xlPrimary).DisplayUnitCustom = 1000000#
.Axes(xlCategory, xlPrimary).HasDisplayUnitLabel = True
.Axes(xlCategory, xlPrimary).DisplayUnitLabel.Caption = "MHz"
ElseIf Me.X_GHz.Value = True Then
.Axes(xlCategory, xlPrimary).DisplayUnit = xlCustom
.Axes(xlCategory, xlPrimary).DisplayUnitCustom = 1000000000#
.Axes(xlCategory, xlPrimary).HasDisplayUnitLabel = True
.Axes(xlCategory, xlPrimary).DisplayUnitLabel.Caption = "GHz"
Else
.Axes(xlCategory, xlPrimary).DisplayUnit = xlNone
End If
.Axes(xlValue, xlPrimary).MinimumScale = UsrFrm2.YSMin.Value
.Axes(xlValue, xlPrimary).MaximumScale = UsrFrm2.YSMax.Value
.Axes(xlValue, xlPrimary).MajorUnitIsAuto = True
.Axes(xlValue, xlPrimary).MinorUnitIsAuto = True
.Axes(xlValue, xlPrimary).HasTitle = True
.Axes(xlValue, xlPrimary).TickLabels.NumberFormat = "General"
.Axes(xlValue, xlPrimary).AxisTitle.Characters.Font.FontStyle = "Normal"
End With
请给我一些建议
做或不做,都没有尝试——尤达,绝地大师
Chart
s不仅仅是Excel
,而是跨所有办公应用程序。因此,它们的对象也不是本地Excel
对象<代码>所有上限,小型上限
。。。是Font2
对象的成员
获取Font2
对象有时有点棘手
假设我们有以下图表:
然后,应执行以下VBA
:
Sub test()
Dim oChart As Chart
Dim oFont2 As Font2
Set oChart = ActiveChart
With oChart
Set oFont2 = .Axes(xlCategory, xlPrimary).AxisTitle.Format.TextFrame2.TextRange.Font
oFont2.Allcaps = msoTrue
oFont2.Allcaps = msoFalse
oFont2.Smallcaps = msoTrue
oFont2.Smallcaps = msoFalse
End With
End Sub