如何设置图表轴上的标签对齐方式?
我必须仅使用 VBA 在 Excel 中制作柱形图(无需用户输入)。
我想格式化 x 轴的标签,以便每个标签的对齐变为 -270 度。 这可以通过更改“格式轴”对话框的“对齐”选项卡中的“自定义角度”属性来手动完成。
我录制了一个宏,但 Excel 似乎没有记录对齐步骤。
I have to make column charts in Excel using VBA only (no user input).
I want to format the labels of the x-axis so that the alignment for every label becomes -270 degrees. This can be done manually by changing the "Custom angle" property in the "Alignment" tab of the "Format Axis" Dialog.
I recorded a macro but Excel does not seem to be recording the alignment step.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(3)
如果您使用的是 Excel 2007,请尝试使用早期版本,因为 2007 的宏记录器有点残缺。
这就是我得到的:
If you are using Excel 2007, try using an earlier version because 2007's macro recorder is a bit crippled.
This is what I got:
关于.Activate
老派的 VBA 宏经常会让人们认为您必须“激活”并反对使其成为“当前”。 就像您单击图形表示一样,您使用鼠标和键盘所做的一切都会被激活的对象接收。 Microsoft Office 产品的“宏生成器”是这种编码风格的罪魁祸首。
然而,在 VBA 编程或使用 C# 或其他流行语言的 Office API 的世界中,这不是应该做的事情。
要修改图表对象、线条等,您可以通过其对象引用对对象本身进行操作。 一旦获得它,您就可以访问所有方法和属性,并且“激活”不是这个概念的一部分。 如果由于某种原因您实际上希望让对象获得一些焦点以便用户看到它 - 视觉对象通常有一个“Activate()”函数可以调用。
在此示例中,图表中多个系列的线宽设置为 1:
在过去(甚至仍然),财务人员进行 Excel 编程,并使他们的工作表疯狂地闪烁和动画,因为他们认为和对象需要接收“焦点” ” 进行修改。
好吧,现在有人这么说,因为它在过去 40 年里一直“困扰”我。
About .Activate
Old school VBA macros often lead people to think you have to "activate" and object to make it "current". Like you click a graphical representation and everything you do with mouse and keyboard is received by the activated object. The "macro generator" for the Microsoft Office products is to blame for this coding style.
However, in the world of VBA programming or using the Office API;s from C# or other popular languages — that is not how it should be done.
To modify a chart object, line etc, you can operate on the object itself by its object reference. Once you obtained it you can access all the methods and properties and "activation" is not part of the concept. If you by some reason actually want to have the object receive some focus for the user to see it — visual objects normally have an "Activate()" function to call.
In this example the line width of multiple series in a chart is set to 1:
In the old days (or even still) financial people do Excel programming and make their worksheets flash and animate like crazy because they think and object needs to receive "focus" to be modified.
Well now it has been said as it has been "bothering" me for the last 40 years.