- 帖子
- 2035
- 主題
- 24
- 精華
- 0
- 積分
- 2031
- 點名
- 0
- 作業系統
- Win7
- 軟體版本
- Office2010
- 閱讀權限
- 100
- 性別
- 男
- 註冊時間
- 2012-3-22
- 最後登錄
- 2024-2-1
|
回復 11# whirlwind963
回復 13# GBKEE
星期日無聊,便動筆修改了 GBKEE 大大的程式: (望不要介意)- Option Explicit
- Sub Ex2()
- Dim j As Integer, k As Integer, MyPath As String, MyFile As String
-
- Application.ScreenUpdating = False
-
- ActiveSheet.Pictures.Delete
- j = 2
- While Cells(j, "C") <> "" ' C欄為檔名
- For k = 1 To 2
- MyPath = Cells(j, k)
- ' A欄,B欄為位址 例如: D:\My Pictures\15\ 、及 E:\Amazing Pictures\16\ 等等。
- If UCase(Cells(j, "C")) Like "*ABCD*" Then ' 字串中有"ABCD"
- On Error Resume Next
- MyFile = Dir(MyPath & "*" & Cells(j, "C") & "*.*")
- If MyFile <> "" Then
- Cells(j, IIf(k = 1, 4, 5)).Select ' D,E欄
- With ActiveSheet.Pictures.Insert(MyPath & MyFile)
- .ShapeRange.LockAspectRatio = msoFalse
- .ShapeRange.Height = 100#
- .ShapeRange.Width = 100#
- .ShapeRange.Rotation = 0#
- .Placement = xlMoveAndSize
- .PrintObject = True
- End With
- End If
- End If
- Next
- j = j + 1
- Wend
- Range("C2").Select
- Application.ScreenUpdating = True
- End Sub
複製代碼 |
|