返回列表 上一主題 發帖

[發問] 萬用字元-抓圖片

[發問] 萬用字元-抓圖片

在A2輸入檔名將圖片顯示在B2
能使用萬用字元嗎?
例如:檔名為ABCDEFG.JPG我在A2輸入ABC也能顯示ABCDEFG的圖片
以下是我的程式碼
請問該如何改呢
Sub Macro1()
    j = 2
    While Cells(j, "A") <> ""
        NN = Cells(j, "A")
        Cells(j, "B").Select
        On Error Resume Next
        ActiveSheet.Pictures.Insert("D:\My Pictures" & NN).Select
        Selection.ShapeRange.LockAspectRatio = msoTrue
        Selection.ShapeRange.Height = 100#
        Selection.ShapeRange.Width = 100#
        Selection.ShapeRange.Rotation = 0#
        With Selection
        .Placement = xlMoveAndSize
        .PrintObject = True
        End With
    j = j + 1
    Wend
    Range("A2").Select
End Sub

回復 2# Hsieh

如果這一行改成
ActiveSheet.Pictures.Insert("D:\My Pictures\" & NN & "*.JPG").Select
可行嗎?還是只能輸入完整的檔案名稱
還是有其他的改法

TOP

        靜思自在 : 小事不做、大事難成。
返回列表 上一主題