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

[µo°Ý] ÃöÁä¦r§ì¹Ï¤ù

[µo°Ý] ÃöÁä¦r§ì¹Ï¤ù

½Ð°Ý¤@­Ó¸ê®Æ§¨¸Ì­±¦³«Ü¦hªº¹Ï¤ù
§Ú±qC2¶}©l¿é¤JÀɦW
¦ý§Ú¥uª¾¹DÃöÁä¦r
¨Ò¦p:ABCD123456  §Ú¥u¿é¤JABCD
³o¼Ë¤]¯à§ì¨ì¹Ï¤ù
¤U­±ªºµ{¦¡½X­þ¸Ì¦³¿ù¶Ü
³Â·Ð¦U¦ì~À°§Ú¬Ý¤@¤U
Sub Macro1()
    j = 2
    MyPath = "C:\My Pictures\"
    MyFile = Dir(MyPath & Cells(j, "C") & "*.jpg")
    While Cells(j, "C") <> ""
        NN = Cells(j, "C")
        Cells(j, "D").Select
        On Error Resume Next
        ActiveSheet.Pictures.Insert(MyFile).Select
        Selection.ShapeRange.LockAspectRatio = msoTrue
        Selection.ShapeRange.Height = 100#
        Selection.ShapeRange.Width = 100#
        Selection.ShapeRange.Rotation = 0#
        With Selection
        .Placement = xlMoveAndSize
        .PrintObject = True
        End With
    j = j + 1
    Wend
    Range("C2").Select
End Sub

¦^´_ 11# whirlwind963
¦^´_ 13# GBKEE
¬P´Á¤éµL²á¡A«K°Êµ§­×§ï¤F GBKEE ¤j¤jªºµ{¦¡¡G (±æ¤£­n¤¶·N)
  1. Option Explicit

  2. Sub Ex2()
  3.     Dim j As Integer, k As Integer, MyPath As String, MyFile As String
  4.    
  5.     Application.ScreenUpdating = False
  6.    
  7.     ActiveSheet.Pictures.Delete
  8.     j = 2
  9.     While Cells(j, "C") <> ""                           '  CÄ欰ÀɦW
  10.         For k = 1 To 2
  11.             MyPath = Cells(j, k)                       
  12.            '  AÄæ,BÄ欰¦ì§} ¨Ò¦p: D:\My Pictures\15\ ¡B¤Î E:\Amazing Pictures\16\ µ¥µ¥¡C
  13.             If UCase(Cells(j, "C")) Like "*ABCD*" Then  ' ¦r¦ê¤¤¦³"ABCD"
  14.                 On Error Resume Next
  15.                 MyFile = Dir(MyPath & "*" & Cells(j, "C") & "*.*")
  16.                 If MyFile <> "" Then
  17.                     Cells(j, IIf(k = 1, 4, 5)).Select   ' D,EÄæ
  18.                     With ActiveSheet.Pictures.Insert(MyPath & MyFile)
  19.                         .ShapeRange.LockAspectRatio = msoFalse
  20.                         .ShapeRange.Height = 100#
  21.                         .ShapeRange.Width = 100#
  22.                         .ShapeRange.Rotation = 0#
  23.                         .Placement = xlMoveAndSize
  24.                         .PrintObject = True
  25.                     End With
  26.                 End If
  27.             End If
  28.         Next
  29.         j = j + 1
  30.     Wend
  31.     Range("C2").Select
  32.     Application.ScreenUpdating = True
  33. End Sub
½Æ»s¥N½X

TOP

¦^´_ 11# whirlwind963
  1. Option Explicit
  2. Sub Ex()
  3.     Dim j As Integer, MyPath As String, MyFile As String, k, L
  4.     For k = 1 To 2                          'A,BÄæ
  5.         For L = 4 To 5                      'D,EÄæ
  6.             j = 2
  7.             While Cells(j, "C") <> ""       'CÄ欰ÀɦW
  8.                 MyPath = Cells(j, k)        'AÄæ,BÄ欰¦ì§}
  9.                 If UCase(Cells(j, "C")) Like "*W*" Then  '¦r¦ê¤¤¦³"ABCD"
  10.                     On Error Resume Next
  11.                     MyFile = Dir(MyPath & "*" & Cells(j, "C") & "*.*")       '  C2 = "ABCD" ->"1AABCD.png"
  12.                     If MyFile <> "" Then
  13.                         Cells(j, L).Select   'D,EÄæ
  14.                         With ActiveSheet.Pictures.Insert(MyPath & MyFile)
  15.                             .ShapeRange.LockAspectRatio = msoFalse
  16.                             .ShapeRange.Height = 100#
  17.                             .ShapeRange.Width = 100#
  18.                             .ShapeRange.Rotation = 0#
  19.                             .Placement = xlMoveAndSize
  20.                             .PrintObject = True
  21.                         End With
  22.                     End If
  23.                 End If
  24.                 j = j + 1
  25.             Wend
  26.             Range("C2").Select
  27.         Next
  28.     Next
  29. End Sub
½Æ»s¥N½X

TOP

¦^´_  c_c_lai
À°§Ú¬Ý¤@¤U
§Ú·Q­n¦bAÄæBÄæ©ñ¦ì§}
CÄ欰¹Ï¤ùÀɦW
DÄ欰Åã¥ÜAªº¹Ï¤ù
EÄæÅã¥ÜBªº¹Ï¤ù
¨Ï ...
whirlwind963 µoªí©ó 2012-12-15 09:45

§Aªº°j°é³B²z¦a«D±`©_©Ç¡A

  1. For k = 1 To 2
  2.         For l = 4 To 5
  3.                j = 2
  4.               While Cells(j, "C") <> ""
  5.                       '  ......
  6.                       j = j + 1
  7.               Wend      '    ¨C¦¸°j°é³£±qÀY¶]¤@¦¸
  8.         Next
  9. Next
½Æ»s¥N½X
§A§â¦¹ÀɮפW¶Ç¡A§Ú¹ê¦aºt½m¤@¦¸¡C

TOP

¦^´_ 9# c_c_lai
À°§Ú¬Ý¤@¤U
§Ú·Q­n¦bAÄæBÄæ©ñ¦ì§}
CÄ欰¹Ï¤ùÀɦW
DÄ欰Åã¥ÜAªº¹Ï¤ù
EÄæÅã¥ÜBªº¹Ï¤ù
¨Ï¥ÎFOR °j°é
¹Ï¤ù·|¦bDÄæ­«Å|
¸Ó«ç»ò§ï©O
     Option Explicit

    Sub Ex()
        Dim j As Integer, MyPath As String, MyFile As String, k, l

        For k = 1 To 2
           For l = 4 To 5
          j = 2
        While Cells(j, "C") <> "" 'C2¬°ÀɦW
         MyPath = Cells(j, k)  'A2 B2¬°¦ì§}
            If UCase(Cells(j, "C")) Like "*W*" Then  '¦r¦ê¤¤¦³"ABCD"
               '  UCase ¨ç¼Æ ¶Ç¦^¤@­Ó Variant (String)¡A©Ò§t¬°Âন¤j¼g¤§¦r¦ê¡C
                Cells(j, l).Select   'D2 E2¬°¹Ï¤ù
                On Error Resume Next
                MyFile = Dir(MyPath & "*" & Cells(j, "C") & "*.*")       '  C2 = "ABCD" ->"1AABCD.png"

                If MyFile <> "" Then
                    With ActiveSheet.Pictures.Insert(MyPath & MyFile)
                        '  .ShapeRange.LockAspectRatio = msoTrue
                        '  ¦b½Õ¾ã¹Ï®×¤j¤p®É¡A¥i¥H¤À§O¦a½Õ¾ã¹Ï®×ªºªø«×©M¼e«×
                        .ShapeRange.LockAspectRatio = msoFalse
                        .ShapeRange.Height = 100#
                        .ShapeRange.Width = 100#
                        .ShapeRange.Rotation = 0#
                        .Placement = xlMoveAndSize
                        .PrintObject = True
                    End With
                End If
            End If
            j = j + 1
        Wend
        Range("C2").Select
        Next
        Next
    End Sub

TOP

¦^´_ 8# whirlwind963
  1. Option Explicit
  2. Sub Ex() '¶Ç¦^¸ê®Æ§¨¤¤²Å¦X[C2] ªºÀÉ®×
  3.     Dim j As Integer, MyPath As String, xlJpg As String
  4.     j = 2
  5.     ActiveSheet.Pictures.Delete
  6.     MyPath = "C:\My Pictures\"
  7.     'Dir ¨ç¼Æ ¶Ç¦^¤@­Ó String ¡A¥Î¥Hªí¥Ü¦X¥G±ø¥ó¡BÀÉ®×ÄÝ©Ê¡BºÏºÐ¼Ð°Oªº¤@­ÓÀɮצWºÙ¡B©Î¥Ø¿ý¡BÀɮק¨¦WºÙ¡C
  8.     xlJpg = Dir(MyPath & [C2] & "*.JPG")       '¶}ÀY= [C2]ªº¦r¦ê
  9.    'xlJpg = Dir(MyPath & "*" & [C2] & "*.JPG")  '¥]§t[C2]ªº¦r¦ê
  10.    'xlJpg = Dir(MyPath & "*" & [C2] & ".JPG")   '¥]§t[C2]ªº¦r¦ê¦b§ÀºÝ
  11.     Do While xlJpg <> ""
  12.        Cells(j, "D").Select
  13.         With ActiveSheet.Pictures.Insert(MyPath & xlJpg)
  14.             '  .ShapeRange.LockAspectRatio = msoTrue
  15.             '  ¦b½Õ¾ã¹Ï®×¤j¤p®É¡A¥i¥H¤À§O¦a½Õ¾ã¹Ï®×ªºªø«×©M¼e«×
  16.             .ShapeRange.LockAspectRatio = msoFalse
  17.             .ShapeRange.Height = IIf(.ShapeRange.Height > 98, 98, .ShapeRange.Height)
  18.             .ShapeRange.Width = IIf(.ShapeRange.Width > 150, 150, .ShapeRange.Width)
  19.             .ShapeRange.Rotation = 0#
  20.             .Placement = xlMoveAndSize
  21.             .PrintObject = True
  22.         End With
  23.         j = j + 1
  24.         xlJpg = Dir
  25.     Loop
  26.     Range("C2").Select
  27. End Sub
½Æ»s¥N½X

TOP

¦^´_ 8# whirlwind963
  1. Option Explicit

  2. Sub Ex()
  3.     Dim j As Integer, MyPath As String, MyFile As String
  4.    
  5.     j = 2
  6.     MyPath = "C:\My Pictures\"
  7.    
  8.     While Cells(j, "C") <> ""
  9.         If UCase(Cells(j, "C")) Like "*ABCD*" Then  '¦r¦ê¤¤¦³"ABCD"
  10.            '  UCase ¨ç¼Æ ¶Ç¦^¤@­Ó Variant (String)¡A©Ò§t¬°Âন¤j¼g¤§¦r¦ê¡C
  11.             Cells(j, "D").Select
  12.             
  13.             Selection.RowHeight = 100
  14.             Selection.ColumnWidth = 25
  15.             
  16.             On Error Resume Next
  17.             MyFile = Dir(MyPath & "*" & Cells(j, "C") & "*.*")       '  C2 = "ABCD" ->"1AABCD.png"

  18.             If MyFile <> "" Then
  19.                 With ActiveSheet.Pictures.Insert(MyPath & MyFile)
  20.                     '  .ShapeRange.LockAspectRatio = msoTrue
  21.                     '  ¦b½Õ¾ã¹Ï®×¤j¤p®É¡A¥i¥H¤À§O¦a½Õ¾ã¹Ï®×ªºªø«×©M¼e«×
  22.                     .ShapeRange.LockAspectRatio = msoFalse
  23.                     .ShapeRange.Height = IIf(.ShapeRange.Height > 98, 98, .ShapeRange.Height)
  24.                     .ShapeRange.Width = IIf(.ShapeRange.Width > 150, 150, .ShapeRange.Width)
  25.                     .ShapeRange.Rotation = 0#
  26.                     .Placement = xlMoveAndSize
  27.                     .PrintObject = True
  28.                 End With
  29.             End If
  30.         End If
  31.         j = j + 1
  32.     Wend
  33.     Range("C2").Select
  34. End Sub
½Æ»s¥N½X

TOP

¦^´_ 6# GBKEE
¤£¦n·N«ä
§Ú·Q­nªº¥¿¦n¬O¬Û¤Ïªº
°²³]ÀɦW¬°ABCD123456.jpg
§Ú¦bC2¿é¤JABCD
D2¯àÅã¥ÜABCD123456.JPGªº¹Ï¤ù

TOP

¦^´_ 6# GBKEE
§Ú¤w¸g­×¥¿§¹¦¨¡A¦p¹Ï¡AÁÂÁ±z¡I
  1. Option Explicit
  2. Sub Ex()
  3.     Dim j As Integer, MyPath As String
  4.    
  5.     j = 2
  6.     MyPath = "C:\My Pictures\"
  7.    
  8.     While Cells(j, "C") <> ""
  9.         If UCase(Cells(j, "C")) Like "*ABCD*" Then  '¦r¦ê¤¤¦³"ABCD"
  10.            'UCase ¨ç¼Æ ¶Ç¦^¤@­Ó Variant (String)¡A©Ò§t¬°Âন¤j¼g¤§¦r¦ê¡C
  11.             Cells(j, "D").Select
  12.             
  13.             Selection.RowHeight = 100
  14.             Selection.ColumnWidth = 25
  15.             
  16.             On Error Resume Next
  17.             If Dir(MyPath & Cells(j, "C")) <> "" Then
  18.                 With ActiveSheet.Pictures.Insert(MyPath & Cells(j, "C"))
  19.                     '  .ShapeRange.LockAspectRatio = msoTrue
  20.                     '  ¦b½Õ¾ã¹Ï®×¤j¤p®É¡A¥i¥H¤À§O¦a½Õ¾ã¹Ï®×ªºªø«×©M¼e«×
  21.                     .ShapeRange.LockAspectRatio = msoFalse
  22.                     .ShapeRange.Height = IIf(.ShapeRange.Height > 98, 98, .ShapeRange.Height)
  23.                     .ShapeRange.Width = IIf(.ShapeRange.Width > 150, 150, .ShapeRange.Width)
  24.                     .ShapeRange.Rotation = 0#
  25.                     .Placement = xlMoveAndSize
  26.                     .PrintObject = True
  27.                 End With
  28.             End If
  29.         End If
  30.         j = j + 1
  31.     Wend
  32.     Range("C2").Select
  33. End Sub
½Æ»s¥N½X

TOP

¦^´_ 5# c_c_lai
2# ¦³»~ ¤w§ó¥¿
  1. Option Explicit
  2. Sub Ex()
  3.     Dim j As Integer, MyPath As String
  4.     j = 2
  5.     MyPath = "D:\My Pictures\"
  6.     While Cells(j, "C") <> ""
  7.         If UCase(Cells(j, "C")) Like "*ABCD*" Then  '¦r¦ê¤¤¦³"ABCD"
  8.            'UCase ¨ç¼Æ ¶Ç¦^¤@­Ó Variant (String)¡A©Ò§t¬°Âন¤j¼g¤§¦r¦ê¡C
  9.             Cells(j, "D").Select
  10.             Selection.RowHeight = 82
  11.            If Dir(MyPath & Cells(j, "C")) <> "" Then
  12.                 With ActiveSheet.Pictures.Insert(MyPath & Cells(j, "C"))
  13.                     '  .ShapeRange.LockAspectRatio = msoTrue
  14.                     '  ¦b½Õ¾ã¹Ï®×¤j¤p®É¡A¥i¥H¤À§O¦a½Õ¾ã¹Ï®×ªºªø«×©M¼e«×
  15.                     .ShapeRange.LockAspectRatio = msoFalse
  16.                     .ShapeRange.Height = IIf(.ShapeRange.Height > 100, 100, .ShapeRange.Height)
  17.                     .ShapeRange.Width = IIf(.ShapeRange.Width > 200, 200, .ShapeRange.Width)
  18.                     .ShapeRange.Rotation = 0#
  19.                     .Placement = xlMoveAndSize
  20.                     .PrintObject = True
  21.                 End With
  22.             End If
  23.         End If
  24.         j = j + 1
  25.     Wend
  26.     Range("C2").Select
  27. End Sub
½Æ»s¥N½X

TOP

        ÀR«ä¦Û¦b : ¤Ó¶§¥ú¤j¡B¤÷¥À®¦¤j¡B§g¤l¶q¤j¡A¤p¤H®ð¤j¡C
ªð¦^¦Cªí ¤W¤@¥DÃD