首页 > 编程语言 > 详细

vba parse错误

时间:2020-03-03 14:04:56      阅读:86      评论:0      收藏:0      [点我收藏+]
技术分享图片
Sub getpicture()Dim d, i&, sp As Shape, arrSet d = CreateObject("scripting.dictionary")For Each sp In Sheet1.Shapes   If sp.Type = msoPicture Then      Set d(sp.TopLeftCell.Offset(, -1).Value) = sp   End IfNextarr = Sheets(2).Range([a2], [a65536].End(3))For i = 1 To UBound(arr)   If d.exists(arr(i, 1)) Then      d(arr(i, 1)).Copy      Cells(i + 1, 2).Select      ActiveSheet.Paste   End IfNextActiveWindow.ScrollRow = 1
‘
‘End Sub windows api
Private Declare Function timeGetTime Lib "winmm.dll" () As Long

 sleep(毫秒)
Sub sleep(T As Long)
    Dim time1 As Long
    time1 = timeGetTime
    Do
        DoEvents
    Loop While timeGetTime - time1 < T
End Sub


Sub getpicture()
Dim d, i&, sp As Shape, arr, xb As Workbook

设置图片库数组
Set xb = GetObject(ActiveWorkbook.path & "\图片库.xlsx")
Set xb = GetObject("C:\图片库.xlsx")
Set d = CreateObject("scripting.dictionary")
For Each sp In xb.Sheets(1).Shapes
   If sp.Type = msoPicture Then
      Set d(sp.TopLeftCell.Offset(, -1).Value) = sp
   End If
Next

读取首行
Dim y As Double
y = Selection.Column() 列数

arr = ActiveSheet.Range(Cells(1, y - 1), Cells(65536, y - 1).End(3))
For i = 1 To UBound(arr)
   If d.exists(arr(i, 1)) Then
      sleep 100
      d(arr(i, 1)).Copy
      Cells(i, y).Select
      On Error Resume Next
      ActiveSheet.Paste
   End If
Next
ActiveWindow.ScrollRow = 1

End Sub

Sub deletepicture()
Dim Tupian As Shape
        For Each Tupian In ActiveSheet.Shapes
            If Tupian.Name Like "Picture *" Then Tupian.Delete
        Next

End Sub

Sub 工具栏()
With Application.CommandBars.Add(, , , True)
With .Controls.Add
     .Caption = "匹配图片"
     .TooltipText = "匹配图片"
     .OnAction = "getpicture"
     .Style = msoButtonIconAndCaption
    End With
    .Visible = True
    
    With .Controls.Add
     .Caption = "清除图片"
     .TooltipText = "清除图片"
     .OnAction = "deletepicture"
     .Style = msoButtonIconAndCaption
    End With
    .Visible = True
    End With
   
End Sub
View Code

 

vba parse错误

原文:https://www.cnblogs.com/xinzhyu/p/12401814.html

(0)
(0)
   
举报
评论 一句话评论(0
关于我们 - 联系我们 - 留言反馈 - 联系我们:wmxa8@hotmail.com
© 2014 bubuko.com 版权所有
打开技术之扣,分享程序人生!