用EXCEL 宏 做一个自动加载图片的
发布网友
发布时间:2022-05-07 09:41
我来回答
共1个回答
热心网友
时间:2023-10-24 10:00
Sub InsertPic()
Dim i As Long, sPath As String, sfileName As String
sPath = "D:\pic\"
Application.ScreenUpdating = False
On Error Resume Next
With ThisWorkbook.Sheets("Sheet1")
For i = 1 To 256
If .Cells(1, i) <> "" Then
sfileName = sPath & .Cells(1, i) & ".jpg"
Cells(2, i).Select
.Pictures.Insert (sfileName)
If Err <> 0 Then
MsgBox .Cells(1, i) & ".jpg" & "不存在"
Err = 0
End If
End If
Next i
End With
Application.ScreenUpdating = True
Range("A1").Select
End Sub追问不行,直接弹出不存在
热心网友
时间:2023-10-24 10:00
Sub InsertPic()
Dim i As Long, sPath As String, sfileName As String
sPath = "D:\pic\"
Application.ScreenUpdating = False
On Error Resume Next
With ThisWorkbook.Sheets("Sheet1")
For i = 1 To 256
If .Cells(1, i) <> "" Then
sfileName = sPath & .Cells(1, i) & ".jpg"
Cells(2, i).Select
.Pictures.Insert (sfileName)
If Err <> 0 Then
MsgBox .Cells(1, i) & ".jpg" & "不存在"
Err = 0
End If
End If
Next i
End With
Application.ScreenUpdating = True
Range("A1").Select
End Sub追问不行,直接弹出不存在
热心网友
时间:2023-10-24 10:00
Sub InsertPic()
Dim i As Long, sPath As String, sfileName As String
sPath = "D:\pic\"
Application.ScreenUpdating = False
On Error Resume Next
With ThisWorkbook.Sheets("Sheet1")
For i = 1 To 256
If .Cells(1, i) <> "" Then
sfileName = sPath & .Cells(1, i) & ".jpg"
Cells(2, i).Select
.Pictures.Insert (sfileName)
If Err <> 0 Then
MsgBox .Cells(1, i) & ".jpg" & "不存在"
Err = 0
End If
End If
Next i
End With
Application.ScreenUpdating = True
Range("A1").Select
End Sub追问不行,直接弹出不存在