返回列表 上一主題 發帖

[發問] 如何 插入 資料夾中含子資料夾的 圖片

[發問] 如何 插入 資料夾中含子資料夾的 圖片

本帖最後由 oxrain 於 2011-9-28 15:06 編輯

請問 各位大大  要如何插入 資料夾中 含子資料夾  的圖片呢
因為將東西以資料夾 做分類存放

根目錄在D碟,主資料夾在 D:\PIC 及 D:\PIC01
而 D:\PIC 中有 001~070 不等約莫 50來個資料夾
而 D:\PIC01 中也有 010~070 約40來個

加上 D:\PIC 及 D:\PIC01 下,也有不在子資料夾的jpg檔
請教各位前輩  要如何加入呢?想說一個一個列,但會弄個好幾天,而且好笨...>.<
附上我的程式檔,麻煩各位賜教,我的頭快要爆了
  1. Sub 插入圖片()
  2.         Dim modelno, modelno1, picins As String
  3.         Dim modelno2%
  4.         modelno = InputBox("A1請輸入A1、C6請輸入C6,以此類推", "輸入商品型號起始欄位", "")
  5.         picins = InputBox("插入A欄請輸入A、插入C欄請輸入C,以此類推", "輸入商品圖片插入欄位", "")
  6.         If modelno = "" Or picins = "" Then
  7.           MsgBox("末確實輸入")
  8.         Else
  9.             modelno1 = Left(modelno, 1)
  10.           modelno2 = Mid(modelno, 2, 3)
  11.           Columns("" & picins & ":" & picins & "").Select
  12.           Selection.ColumnWidth = 20
  13.           Rows("" & modelno2 & ":9999").Select
  14.           Selection.RowHeight = 50
  15.           Dim a%
  16.           Dim name As String
  17.             For a = modelno2 To 9999
  18.                 name = Range("" & modelno1 & "" & a & "")
  19.                   If name <> "" Then
  20.                         Range("" & picins & "" & a & "").Select
  21.                           If Dir("D:\PICTURE\001\" & name & ".jpg") <> "" Then
  22.                                 ActiveSheet.Pictures.Insert(P).Select
  23.                                   Selection.ShapeRange.LockAspectRatio = msoTrue
  24.                                   Selection.ShapeRange.Height = 49.5
  25.                                   Selection.ShapeRange.IncrementLeft 0.75
  26.                           Else
  27.                                   Range("" & picins & "" & a & "") = "無圖片"
  28.                           End If
  29.                 End If
  30.             Next
  31.         End If
  32. End Sub
複製代碼

        靜思自在 : 站在半路,比走到目標更辛苦。
返回列表 上一主題