- ©«¤l
- 2035
- ¥DÃD
- 24
- ºëµØ
- 0
- ¿n¤À
- 2031
- ÂI¦W
- 0
- §@·~¨t²Î
- Win7
- ³nÅ骩¥»
- Office2010
- ¾\ŪÅv
- 100
- ©Ê§O
- ¨k
- µù¥U®É¶¡
- 2012-3-22
- ³Ì«áµn¿ý
- 2024-2-1
|
¦^´_ 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- Option Explicit
- Sub Ex()
- Dim fs As Object, f As Variant, e As Variant
- Dim j As Integer, MyPath As String, MyFile As String
-
- j = 2
- MyPath = ActiveWorkbook.Path & "\My Pictures\"
-
- Application.ScreenUpdating = False
-
- Set fs = CreateObject("Scripting.FileSystemObject").GetFolder(MyPath)
- For Each e In fs.subfolders ' ¸ê®Æ§¨¶°¦Xª«¥ó e = "D:\Workspaces\DATA\Excel ½d¨Ò¶°ÀA\TXT\2012-12-12\14"
- ' For Each f In e.Files ' Àɮ׶°¦Xª«¥ó f = "D:\Workspaces\DATA\Excel ½d¨Ò¶°ÀA\TXT\2012-12-12\14\Winter.jpg"
- With Sheets("¤u§@ªí1")
- .Pictures.Delete
- While Cells(j, "C") <> ""
- If UCase(.Cells(j, "C")) Like "*ABCD*" Then '¦r¦ê¤¤¦³"ABCD"
- 'UCase ¨ç¼Æ ¶Ç¦^¤@Ó Variant (String)¡A©Ò§t¬°Âন¤j¼g¤§¦r¦ê¡C
- .Cells(j, "D").Select
-
- Selection.RowHeight = 100
- Selection.ColumnWidth = 25
-
- On Error Resume Next
- ' MyFile = Dir(e & "\*" & Cells(j, "C") & "*.*", vbDirectory)
- MyFile = Dir(e & "\*" & Cells(j, "C") & "*.*")
- If MyFile <> "" Then
- ' With .Pictures.Insert(MyPath & MyFile)
- With .Pictures.Insert(e & "\" & MyFile)
- .Top = Cells(j, "D").Top
- .Left = Cells(j, "D").Left
- .Height = 90
- .Width = 120
- .Cells(j, "D").RowHeight = .Height
- .Cells(j, "D").ColumnWidth = .Width / 5.5
- ' .ShapeRange.LockAspectRatio = msoTrue
- ' ¦b½Õ¾ã¹Ï®×¤j¤p®É¡A¥i¥H¤À§O¦a½Õ¾ã¹Ï®×ªºªø«×©M¼e«×
- ' .ShapeRange.LockAspectRatio = msoFalse
- ' .ShapeRange.Height = IIf(.ShapeRange.Height > 98, 98, .ShapeRange.Height)
- ' .ShapeRange.Width = IIf(.ShapeRange.Width > 150, 150, .ShapeRange.Width)
- ' .ShapeRange.Rotation = 0#
- ' .ShapeRange.IncrementLeft 2#
- ' .ShapeRange.IncrementTop 1#
- ' .Placement = xlMoveAndSize
- ' .PrintObject = True
- End With
- .Cells(j, "E") = MyFile
- End If
- End If
- j = j + 1
- Wend
- .Range("C2").Select
- End With
- ' Next ' For Each f In e.Files
- Next ' For Each e In fs.subfolders
- Application.ScreenUpdating = True
- End Sub
½Æ»s¥N½X |
|