- 帖子
- 5923
- 主題
- 13
- 精華
- 1
- 積分
- 5986
- 點名
- 0
- 作業系統
- win10
- 軟體版本
- Office 2010
- 閱讀權限
- 150
- 性別
- 男
- 來自
- 台灣基隆
- 註冊時間
- 2010-5-1
- 最後登錄
- 2022-1-23
        
|
6#
發表於 2012-12-12 11:27
| 只看該作者
回復 5# c_c_lai
2# 有誤 已更正- Option Explicit
- Sub Ex()
- Dim j As Integer, MyPath As String
- j = 2
- MyPath = "D:\My Pictures\"
- While Cells(j, "C") <> ""
- If UCase(Cells(j, "C")) Like "*ABCD*" Then '字串中有"ABCD"
- 'UCase 函數 傳回一個 Variant (String),所含為轉成大寫之字串。
- Cells(j, "D").Select
- Selection.RowHeight = 82
- If Dir(MyPath & Cells(j, "C")) <> "" Then
- With ActiveSheet.Pictures.Insert(MyPath & Cells(j, "C"))
- ' .ShapeRange.LockAspectRatio = msoTrue
- ' 在調整圖案大小時,可以分別地調整圖案的長度和寬度
- .ShapeRange.LockAspectRatio = msoFalse
- .ShapeRange.Height = IIf(.ShapeRange.Height > 100, 100, .ShapeRange.Height)
- .ShapeRange.Width = IIf(.ShapeRange.Width > 200, 200, .ShapeRange.Width)
- .ShapeRange.Rotation = 0#
- .Placement = xlMoveAndSize
- .PrintObject = True
- End With
- End If
- End If
- j = j + 1
- Wend
- Range("C2").Select
- End Sub
複製代碼 |
|