如何於excel的報價表單上輸入不同的Item帶入不同的圖片
- 帖子
- 5923
- 主題
- 13
- 精華
- 1
- 積分
- 5986
- 點名
- 0
- 作業系統
- win10
- 軟體版本
- Office 2010
- 閱讀權限
- 150
- 性別
- 男
- 來自
- 台灣基隆
- 註冊時間
- 2010-5-1
- 最後登錄
- 2022-1-23
        
|
回復 3# kimie0_0
適用於你1#的檔案- Sub Ex_AutoAddPic()
- Dim Rng(1 To 2) As Range, Rng_First As String, MyPcName As String, Picture_Path As String
- Picture_Path = "D:\photo\"
- With ActiveSheet
- For Each Shp In .Shapes
- If Shp.Type = msoPicture Then Shp.Delete
- Next
- Set Rng(1) = .Cells.Find("Item no:", lookat:=xlWhole, SearchOrder:=xlByRows) 'xlByRows(循列)或 xlByColumns(循欄) 搜尋
- If Not Rng(1) Is Nothing Then
- Rng_First = Rng(1).Address '第一個尋找到 "Item no:" 的位置
- Do
- MyPcName = Picture_Path & Rng(1).Cells(1, 2) & ".jpg"
- If Dir(MyPcName, vbDirectory) <> "" Then
- Set Rng(2) = Rng(1).Cells(-7) '上移8列的Cells位置
- With .Pictures.Insert(MyPcName)
- .Top = Rng(2).Top '插入圖片的頂點,位於工作表從第一列頂端至該範圍頂端的距離
- .Left = Rng(2).Left '插入圖片的左邊,位於工作表從 A 欄左限至該範圍左限的距離
- .Height = Rng(2).Resize(8).Height '插入圖片的範圍的高度
- .Width = Rng(2).Resize(, 2).Width '插入圖片的範圍的寬度
- End With
- End If
- Set Rng(1) = .Cells.FindNext(Rng(1)) '下一個要尋找的字串
- Loop Until Rng_First = Rng(1).Address '回到第一個尋找到 "Item no:" 的位置
- End If
- End With
- End Sub
複製代碼 |
|
|
|
|
|
|
|