- 帖子
- 4901
- 主題
- 44
- 精華
- 24
- 積分
- 4916
- 點名
- 86
- 作業系統
- Windows 7
- 軟體版本
- Office 20xx
- 閱讀權限
- 150
- 性別
- 男
- 來自
- 台北
- 註冊時間
- 2010-4-30
- 最後登錄
- 2025-4-10
               
|
13#
發表於 2012-8-7 00:03
| 只看該作者
本帖最後由 Hsieh 於 2012-8-7 00:13 編輯
回復 12# 周大偉
圖片格式的預設值是大小位置隨儲存格而變
為確保圖片會隨儲存格移動- Private Sub Label1_Click() '新增資料
- Dim Ar(), A As Range, B As Range, C As Range, MyPic As Shape
- Set C = Sheet1.[A:A].Find(TextBox1.Text, lookat:=xlWhole)
- If Not C Is Nothing Then MsgBox ("學號重複,請重新檢查"): Exit Sub
- fd = ThisWorkbook.Path & "\"
- If Dir(fd & "Temp.bmp") <> "" Then Kill fd & "Temp.bmp"
- SavePicture Image1.Picture, fd & "Temp.bmp"
- obs = Array("TextBox1", "TextBox2", "TextBox3", "TextBox4", "TextBox5", "TextBox6", "ComboBox1", "TextBox7", "TextBox8", "TextBox9", "TextBox10", "TextBox11", "ComboBox2")
- For i = 0 To 12
- ReDim Preserve Ar(i)
- Ar(i) = Controls(obs(i)).Text
- Next
- With Sheet1
- Set A = .Cells(.Rows.Count, 1).End(xlUp).Offset(1)
- A.RowHeight = 79.8
- Set B = A.Offset(, 13)
- A.Resize(, 13) = Ar
- Set MyPic = .Shapes.AddPicture(fd & "Temp.bmp", msoFalse, msoCTrue, B.Left, B.Top, B.Width, B.Height)
- MyPic.Placement = xlMoveAndSize '設定圖片大小位置隨儲存格改變
- .Range("A3").CurrentRegion.Sort key1:=.[A4], header:=xlYes '排序
- End With
- Unload Me: UserForm1.Show
- End Sub
複製代碼 |
|