我有这段代码:
Sub InsertPhotos_Click()
Range("Photo1").Select
ActiveSheet.Pictures.Insert("U:\Trial\1.jpg").Select
Selection.ShapeRange.Height = 151.2
Selection.ShapeRange.IncrementLeft 27
Selection.ShapeRange.IncrementTop 3
End Sub
我需要能够命名文件名1-xxxx,但不知道如何使用通配符。当文件名为1时,代码执行我想要的操作。任何帮助都会很棒,谢谢!
答案 0 :(得分:0)
这有用吗?
Sub InsertPhotos_Click()
Dim PhotoString As String
Range("Photo1").Select
PhotoString = Application.InputBox("Type text for picture", "Get Picture", Type:=2)
If PhotoString <> "" Then ' 1. If PhotoString <> ""
ActiveSheet.Pictures.Insert("U:\Trial\1-" & PhotoString & ".jpg").Select
Selection.ShapeRange.Height = 151.2
Selection.ShapeRange.IncrementLeft 27
Selection.ShapeRange.IncrementTop 3
End If ' 1. If PhotoString <> ""
End Sub