ªð¦^¦Cªí ¤W¤@¥DÃD µo©«

[µo°Ý] ¦p¦ó ´¡¤J ¸ê®Æ§¨¤¤§t¤l¸ê®Æ§¨ªº ¹Ï¤ù

¦^´_ 19# GBKEE
GBKEE ª©¤j¡A ¦­¦w!
§Ú¹ê»Ú´ú¤F¤@°}¤l¡Aµo²{ ¤@°õ¦æ¨ì With ActiveSheet.Pictures.Insert(f)
³o¤@¦æ«K¥X²{ 104 ªº¿ù»~°T®§¡A ¸gÀˬd»yªk¤]¨S¿ù¡A´N¬O·|¦³¿ù»~°T®§¡C
¤]¥O§Ú¦Ê«ä¤£¸Ñ¡C §Ú¥t¥~±N¨ä¤¤ GetFolder ªº³B¸Ì¼Ò²Õ©ñ¤J¨ì¥t¤@¤äµ{¦¡
ùØ´ú¸Õ³£«D±`¥¿±`¡A§Ú±Nµ{¦¡½X  (¦bThisWorkbook°õ¦æ) ªþ¤WÅý±z°Ñ¦Ò¡C
  1. Option Explicit

  2. Sub Ex()
  3.     Dim fs As Object, f As Variant, e As Variant
  4.     Dim j As Integer, MyPath As String, MyFile As String
  5.    
  6.     j = 2
  7.     MyPath = ActiveWorkbook.Path & "\My Pictures\"
  8.    
  9.     Application.ScreenUpdating = False
  10.    
  11.     Set fs = CreateObject("Scripting.FileSystemObject").GetFolder(MyPath)
  12.     For Each e In fs.subfolders  ' ¸ê®Æ§¨¶°¦Xª«¥ó e = "D:\Workspaces\DATA\Excel ½d¨Ò¶°ÀA\TXT\2012-12-12\14"
  13.         '  For Each f In e.Files  ' Àɮ׶°¦Xª«¥ó f = "D:\Workspaces\DATA\Excel ½d¨Ò¶°ÀA\TXT\2012-12-12\14\Winter.jpg"
  14.         With Sheets("¤u§@ªí1")
  15.             .Pictures.Delete
  16.             While Cells(j, "C") <> ""
  17.                 If UCase(.Cells(j, "C")) Like "*ABCD*" Then  '¦r¦ê¤¤¦³"ABCD"
  18.                     'UCase ¨ç¼Æ ¶Ç¦^¤@­Ó Variant (String)¡A©Ò§t¬°Âন¤j¼g¤§¦r¦ê¡C
  19.                     .Cells(j, "D").Select
  20.                                        
  21.                      Selection.RowHeight = 100
  22.                      Selection.ColumnWidth = 25
  23.                                             
  24.                      On Error Resume Next
  25.                      '   MyFile = Dir(e & "\*" & Cells(j, "C") & "*.*", vbDirectory)
  26.                      MyFile = Dir(e & "\*" & Cells(j, "C") & "*.*")
  27.                      If MyFile <> "" Then
  28.                          '  With .Pictures.Insert(MyPath & MyFile)
  29.                          With .Pictures.Insert(e & "\" & MyFile)
  30.                              .Top = Cells(j, "D").Top
  31.                              .Left = Cells(j, "D").Left
  32.                              .Height = 90
  33.                              .Width = 120
  34.                              .Cells(j, "D").RowHeight = .Height
  35.                              .Cells(j, "D").ColumnWidth = .Width / 5.5
  36.                              '  .ShapeRange.LockAspectRatio = msoTrue
  37.                              '  ¦b½Õ¾ã¹Ï®×¤j¤p®É¡A¥i¥H¤À§O¦a½Õ¾ã¹Ï®×ªºªø«×©M¼e«×
  38.                              '  .ShapeRange.LockAspectRatio = msoFalse
  39.                              '  .ShapeRange.Height = IIf(.ShapeRange.Height > 98, 98, .ShapeRange.Height)
  40.                              '  .ShapeRange.Width = IIf(.ShapeRange.Width > 150, 150, .ShapeRange.Width)
  41.                              '  .ShapeRange.Rotation = 0#
  42.                              '  .ShapeRange.IncrementLeft 2#
  43.                              '  .ShapeRange.IncrementTop 1#
  44.                              '  .Placement = xlMoveAndSize
  45.                              '  .PrintObject = True
  46.                          End With
  47.                          .Cells(j, "E") = MyFile
  48.                      End If
  49.                 End If
  50.                 j = j + 1
  51.             Wend
  52.             .Range("C2").Select
  53.         End With
  54.         '  Next    '  For Each f In e.Files
  55.     Next           '  For Each e In fs.subfolders
  56.     Application.ScreenUpdating = True
  57. End Sub
½Æ»s¥N½X

TOP

¦^´_ 21# GBKEE
  1. Option Explicit

  2. Sub Ex()
  3.     Dim fs, f, e As Variant, i As Integer, xCol As Integer
  4.    
  5.     Sheets(1).Activate
  6.     ActiveSheet.Pictures.Delete
  7.     xCol = 3    'Äæ¼Æ
  8.     Set fs = CreateObject("Scripting.FileSystemObject").GetFolder("D:\2012-12-12")
  9.     '**ÀÉ®×,¸ê®Æ§¨ªº©R¦W¤¤: ¤£¥i¦³  / \ : * ? < > |  ³o¨Ç¦r¤¸
  10.     For Each e In fs.subfolders  '¸ê®Æ§¨¶°¦Xª«¥ó
  11.         i = 2       '¦C¼Æ
  12.         If Val(e.Name) >= [A1] And Val(e.Name) <= Range("B1") Then '¦pªG§Ú¦bA1¿é¤J06  B1¿é¤J12
  13.         'If e.Name >= 5 And e.Name <= 15 Then    '5 ¨ì 10
  14.             For Each f In e.Files    'Àɮ׶°¦Xª«¥ó
  15.                 If UCase(f) Like "*.JPG" Or UCase(f) Like "*.GIF" Or UCase(f) Like "*.BMP" Then
  16.                 '¹w¨¾¤£¬O¹Ï¤ùÀÉ
  17.                     i = i + 1
  18.                     With ActiveSheet.Pictures.Insert(f)
  19.                         .Top = Cells(i, xCol).Top
  20.                         .Left = Cells(i, xCol).Left
  21.                         .Height = 49.5
  22.                         .Width = 49.5
  23.                         Cells(i, xCol).RowHeight = .Height
  24.                         Cells(i, xCol).ColumnWidth = .Width / 5.5
  25.                     End With
  26.                 End If
  27.             Next
  28.             xCol = xCol + 1   'Äæ¼Æ
  29.         End If
  30.     Next
  31. End Sub
½Æ»s¥N½X

¨Ñ°µ´ú¸Õ¥Î¡G   ´¡¤J¹Ï¤ù2.rar (9.79 KB)

TOP

¦^´_  c_c_lai
2003ª© ¨S¦³¿ù»~!!
¿ù»~ÂI «e  Debug.Print f   ¬Ý¬Ý: ¬O­þ­Ó¹ÏÀÉ,±N¥L§R±¼¸Õ¸Õ
GBKEE µoªí©ó 2012-12-13 12:09

´ú¥XÄpµ²¤F¡A°ÝÃD¥X¦b f  ÅܼƤ§¨Ï¥Î¤W¡G
  1.         With ActiveSheet.Pictures.Insert(f)
½Æ»s¥N½X
·|¥X²{ 1004 ªº¿ù»~°T®§¡A»Ý­×¥¿¬°¡G
  1.         With ActiveSheet.Pictures.Insert(e & "\" & f.Name)
½Æ»s¥N½X
¦p¦¹¬Ý¨Ó¡AFor Each f In e.Files  ªº f ¦b 2003 ¥¦¥i¥H·í¦¨¦r¦êª½±µ³B²z¡A
¦Ó¦b 2010 ®É¡A  f «hµø¬°¤@­Óª«¥ó (Class)¡A¦¹®É¦pªGª½±µ¨Ï¥Î¥¦°õ¦æ
With ActiveSheet.Pictures.Insert(f) ´N·|¥X²{ 1004 ªº¿ù»~°T®§¡C

TOP

        ÀR«ä¦Û¦b : ±o²z­nÄǤH¡A²zª½­n®ð©M¡C
ªð¦^¦Cªí ¤W¤@¥DÃD