返回列表 上一主題 發帖

一個複雜的表單問題

回復 13# Hsieh
先行衷心怠謝謝HSIEH版大大, 小弟把程式再貼上, 排序是可以, 但上傳圖片依然是傳送至最尾, 真的不明, 勞煩大大, 是否小弟須要注意某些情況, 如屬性等. 謝謝謝!

TOP

本帖最後由 Hsieh 於 2012-8-7 00:13 編輯

回復 12# 周大偉
圖片格式的預設值是大小位置隨儲存格而變

    play.gif
為確保圖片會隨儲存格移動
  1. Private Sub Label1_Click() '新增資料
  2. Dim Ar(), A As Range, B As Range, C As Range, MyPic As Shape
  3. Set C = Sheet1.[A:A].Find(TextBox1.Text, lookat:=xlWhole)
  4. If Not C Is Nothing Then MsgBox ("學號重複,請重新檢查"): Exit Sub
  5. fd = ThisWorkbook.Path & "\"
  6. If Dir(fd & "Temp.bmp") <> "" Then Kill fd & "Temp.bmp"
  7. SavePicture Image1.Picture, fd & "Temp.bmp"
  8. obs = Array("TextBox1", "TextBox2", "TextBox3", "TextBox4", "TextBox5", "TextBox6", "ComboBox1", "TextBox7", "TextBox8", "TextBox9", "TextBox10", "TextBox11", "ComboBox2")

  9. For i = 0 To 12
  10.      ReDim Preserve Ar(i)
  11.      Ar(i) = Controls(obs(i)).Text
  12. Next
  13. With Sheet1
  14.    Set A = .Cells(.Rows.Count, 1).End(xlUp).Offset(1)
  15.    A.RowHeight = 79.8
  16.    Set B = A.Offset(, 13)
  17.    A.Resize(, 13) = Ar
  18.    Set MyPic = .Shapes.AddPicture(fd & "Temp.bmp", msoFalse, msoCTrue, B.Left, B.Top, B.Width, B.Height)
  19.    MyPic.Placement = xlMoveAndSize  '設定圖片大小位置隨儲存格改變
  20.    .Range("A3").CurrentRegion.Sort key1:=.[A4], header:=xlYes  '排序
  21. End With
  22. Unload Me: UserForm1.Show
  23. End Sub
複製代碼
學海無涯_不恥下問

TOP

回復 11# Hsieh
謝謝hsieh版大,
輸入可自行排序, 但圖片亦舊排於最尾, 不能跟資料整列顯示於插入排序之欄位. 請大大教導, 謝謝!!

TOP

回復 10# 周大偉

直接排序即可
  1. Private Sub Label1_Click() '新增資料
  2. Dim Ar(), A As Range, B As Range, C As Range
  3. Set C = Sheet1.[A:A].Find(TextBox1.Text, lookat:=xlWhole)
  4. If Not C Is Nothing Then MsgBox ("學號重複,請重新檢查"): Exit Sub
  5. fd = ThisWorkbook.Path & "\"
  6. If Dir(fd & "Temp.bmp") <> "" Then Kill fd & "Temp.bmp"
  7. SavePicture Image1.Picture, fd & "Temp.bmp"
  8. obs = Array("TextBox1", "TextBox2", "TextBox3", "TextBox4", "TextBox5", "TextBox6", "ComboBox1", "TextBox7", "TextBox8", "TextBox9", "TextBox10", "TextBox11", "ComboBox2")

  9. For i = 0 To 12
  10.      ReDim Preserve Ar(i)
  11.      Ar(i) = Controls(obs(i)).Text
  12. Next
  13. With Sheet1
  14.    Set A = .Cells(.Rows.Count, 1).End(xlUp).Offset(1)
  15.    A.RowHeight = 79.8
  16.    Set B = A.Offset(, 13)
  17.    A.Resize(, 13) = Ar
  18.    .Shapes.AddPicture fd & "Temp.bmp", msoFalse, msoCTrue, B.Left, B.Top, B.Width, B.Height
  19.     .Range("A3").CurrentRegion.Sort key1:=.[A4], header:=xlYes  '排序
  20. End With
  21. Unload Me: UserForm1.Show
  22. End Sub
複製代碼
學海無涯_不恥下問

TOP

回復 8# Hsieh
hsieh版大, 好
花了一段時間, 總算能有小許領悟, 版大的技藝實太高招, 版大若能在輸入時, a欄位能自行排序, 就是否可以, 如123456- 123459- 當我輸入123457, 資料便自行排列於123456下..
煩勞大大..謝謝!

TOP

回復 8# Hsieh

明白了, 謝謝大大,

TOP

本帖最後由 Hsieh 於 2012-7-26 21:23 編輯

回復 7# 周大偉

PictureSizeMode屬性控制
play.gif
學海無涯_不恥下問

TOP

大大,
在這裡真是我等學習好地方, 小弟也有一問題請教, 圖片輸入時, 尺寸比例有小許偏差, 意思是指, 圖片可能變濶了, 或拉長了, 可否做到圖片比例能自動調節為於Image1控制項中, 當圖片輸入後, 圖片比例不會令照片拉長或拉濶..謝謝!!

TOP

回復 5# Hsieh
謝謝大大, 問題已解決,
祝願快樂

TOP

本帖最後由 Hsieh 於 2012-7-26 15:12 編輯

回復 4# 317

我測試沒問題,可能你沒有將檔案解壓縮到電腦位置
導致沒有權限寫入檔案
play.gif
學海無涯_不恥下問

TOP

        靜思自在 : 能幹不幹,不如苦幹實幹。
返回列表 上一主題