小樱知识 > 生活常识vba读取excel文件内容(让vba引用单元格里的值方法)

vba读取excel文件内容(让vba引用单元格里的值方法)

提问时间:2022-03-16 13:27:07来源:小樱知识网


如果想要提取Excel界面的某个图标,可以使用VBA的CommandBars对象将其提取出来:

Application.CommandBars.Controls.intFaceId

Application.CommandBars.Controls.CopyFace

intFaceId从1-18028

Option ExplicitSub 获取Excel中的所有内置控件的FaceId和图像()    Dim cbr As CommandBar, ctl As CommandBarButton    Dim intCol As Integer, intRow As Integer    Dim intFaceId As Integer    If Application.WorksheetFunction.CountA(Cells) <> 0 Then        MsgBox "活动工作表中包含数据,请选择一个空工作表!"        Exit Sub    End If    On Error GoTo errTrap '错误捕捉    Application.ScreenUpdating = False    Set cbr = Application.CommandBars.Add(MenuBar:=False, Temporary:=True)    Set ctl = cbr.Controls.Add(Type:=msoControlButton, Temporary:=True)    intRow = 1    Do        For intCol = 1 To 8            intFaceId = intFaceId + 1            Application.StatusBar = "FaceID=" & intFaceId  ' 状态栏提示一下            ctl.FaceId = intFaceId            ctl.CopyFace '复制图标图像,如果复制的是不可见图像,会出现编号为1004的错误            ActiveSheet.Paste Cells(intRow, intCol + 1) '粘贴图标图像            Cells(intRow, intCol).Value = intFaceId        Next intCol        intRow = intRow + 1    LooperrTrap: '错误处理    If Err.Number = 1004 Then Resume Next    Application.StatusBar = False    cbr.Delete    Application.ScreenUpdating = TrueEnd Sub

效果:

最后一页:

-End-

以上内容就是为大家推荐的vba读取excel文件内容(让vba引用单元格里的值方法)最佳回答,如果还想搜索其他问题,请收藏本网站或点击搜索更多问题

内容来源于网络仅供参考
二维码

扫一扫关注我们

版权声明:所有来源标注为小樱知识网www.xiaoyin02.com的内容版权均为本站所有,若您需要引用、转载,只需要注明来源及原文链接即可。

本文标题:vba读取excel文件内容(让vba引用单元格里的值方法)

本文地址:https://www.xiaoyin02.com/shcs/119244.html

相关文章