excel - 使用 CommandButton Collection 更新命令按钮上的字体
问题描述
我想使用 vba 更改几个工作表上所有 ActiveX 命令按钮的字体。我知道可以使用 vba 更新字体,因为此代码将为单个按钮执行此操作
Private Sub CommandButton49_Click()
CommandButton49.Font = "Arial Rounded MT Bold"
End Sub
我在这个网站上看到了一种获取收藏的方法
Dim MyShapes As OLEObjects
Dim btn As OLEObject
Dim cbtn As CommandButton
'OLE Programmatic Identifiers for Commandbuttons = Forms.CommandButton.1
Set MyShapes = ActiveSheet.OLEObjects
For Each btn In MyShapes
If btn.progID = "Forms.CommandButton.1" Then
btn.Object.Font = "Arial"
End If
Next
但是这段代码给出了一个运行时错误 438 - 对象不支持这个属性或方法,这很奇怪,因为我可以使用这个方法来显示字体 - 即 msgbox btn.Object.Font 将显示当前字体。
我错过了什么?
解决方案
推荐阅读
- bootstrap-4 - 引导 reCAPTCHA 客户端验证
- emacs - 如何获得 emacs 编译模式以扩展由其他脚本或什至在它启动的环境中而不是 .bashrc 等中的别名
- python - 如何在 python 中打开 .ProcSpec 文件?
- javascript - 无法加载 Blob URL
- c# - 在“团队”类型的对象上找不到成员“group@odata.bind”
- python - 如何让第 3 方应用程序与烧瓶交互
- java - 将数组从 Java 传递给存储过程(Oracle)
- c# - 如何正确从选择返回异步?
- python - OpenCV 将 HSL 转换为 RGB
- flutter - Android studio 停止检测 Android 设备但识别 iOS 设备