Home > Software engineering >  Vba shape use problem
Vba shape use problem

Time:04-03

I just learning VBA code written, and now have a problem please expert advice,
Background: match the sheet2 of qr code picture taped to the corresponding area in the range in the sheet1., matched elements: "equipment number: * * * * - * * * * * - * * * * * - * * * *",
Problem: 1. The image by changing the size, can adapt to sheet1 area requirements, the synchronous sheet2 ranked qr code follow change position and size!
2. This difference in shapes. Addpicture image processing method, so this is how to set up in the picture?
Test (Sub)
Dim f As String
Dim f1 As String
Dim h As String
Dim w As Integer
Dim y As Integer
Dim z As Integer
Dim x As Integer
Dim w1 As Integer
Dim tp As Range
Dim RNG As Range
Dim I As an Integer, SHPS
Dim shps1
For x=1 To 20
For y=1 To 20
For w=1 To 20
For z=1 To 20
Application. ScreenUpdating=False
F=Sheet1. Cells (x, y). The Text
H=Left (Sheet2. Cells (w, z), 5)
If h="equipment number:" Then
Worksheets (" Sheet2 "). Activate
F1=Right (Cells (w, z), Len (Cells (w, z)) to 5)
If f=f1 Then
'tp=Range (Sheet2. Cells (+ 2 x, y))
'Range (Sheet1. Cells (z - w - 1, 3))=tp
Worksheets (" sheet2 "). Select
W1=w - 2
The Set RNG=Sheet2. Range (Cells (w1, z), Cells (w1 + 1, z))
The Set of SHPS=RNG. Worksheet. Shapes
For I=SHPS. Count To 1 Step - 1 'reverse circulation picture
If Not intersects (SHPS (I). TopLeftCell, RNG) Is Nothing Then 'image position Is detected with this overlap Is deleted
Worksheets (" Sheet1 "). Activate
The Set shps1=SHPS (I)
With shps1
. Left=3
. Top=3
Width=Cells (2 x -, y - 3). The Width + Cells (2 x -, y - 2). The Width of 1
Height=Cells (- 2 x, y). The Height + Cells (1 x, y). Height + Cells (x + 1, y). Height + Cells (x, y). The Height of 1
End With
Shps1. Copy
Range (Cells (2 x -, y - 3), Cells (x + 1, y - 2)). Select
ActiveSheet. Paste
End the If
Next I
End the If
End the If
Next
Next
Next
Next
End Sub
  •  Tags:  
  • VBA
  • Related