- 帖子
- 4901
- 主題
- 44
- 精華
- 24
- 積分
- 4916
- 點名
- 142
- 作業系統
- Windows 7
- 軟體版本
- Office 20xx
- 閱讀權限
- 150
- 性別
- 男
- 來自
- 台北
- 註冊時間
- 2010-4-30
- 最後登錄
- 2026-7-16
                
|
回復 21# 周大偉 - Private Sub Label1_Click() '新增資料
-
- Dim Ar(), A As Range, B As Range, C As Range, MyPic As Shape
- Set dpic = CreateObject("Scripting.Dictionary")
-
- 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)
-
- For Each pic In Sheet1.Shapes
- If pic.Type = 13 Then dpic(.Cells(pic.TopLeftCell.Row, 1).Value) = pic.Name
- Next
-
- .Range("A3").CurrentRegion.Sort key1:=.[A4], Header:=xlYes '排序
- If Val(Application.Version) > 11 Then
- For Each A In .Range(.[A4], .Cells(.Rows.Count, 1).End(xlUp))
- .Shapes(dpic(A.Value)).Top = A.Top
- Next
- End If
-
- End With
-
- Unload Me: UserForm1.Show
-
- End Sub
複製代碼 |
|