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

[µo°Ý] VBA ¶}°_³Ì·s¤å¦r¤å¥óÀÉ ¨Ã­×§ï

³ø§i ª©¥D °ÝÃD¸Ñ¨M@@


¦ý¬O²{¦b¤]¬O¹J¨ì¤@­Ó°ÝÃD
§Ú­n¶×¤JTXT¨ìEXCEL ¥L¤]­nª¾¹D ³Ì·s¦sÀɤé´Áªº¨º¤@­Ó¦b¶×¤J@@

TOP

ÁÂÁª©¥D ¨S¿ù¬O³Ì·s®É¶¡
¦]¬°§Ú­Ì°µ§¹¤@¥ó¨Æ ¥L·|¦Û°ÊÀx¦s¦b¤@®æ¸ê®Æ§¨¤º
¦]¬°§Ú¬O¥Î¿ý»s¥¨¶°¨Ó©ñ¤J EXCEL ¥i¬O§Ú¬O¥ÎªÅ¥Õ®æ¨Ó¤À³Î
©Ò¥H»Ý­n«e­±³£­n¦³ªÅ¥Õ@@

ª©¤j ¥i¬O§Ú¿ý»s«á §Ú¶×¤JTXTÀÉ ¶]¨ì  .CommandType = 0
¥L³£»¡©I¥s¤£¥¿½T

TOP

¦^´_ 1# vm3503ru8
¬O³Ì·s¦sÀɪº¤é´Á®É¶¡¶Ü?
  1. Option Explicit
  2. Sub Ex­×§ï¤å¥óÀÉ®×()
  3.     Dim F As Object, E, AR(), i As Integer, A As Variant, xFile As String
  4.     'Set F = CreateObject("Scripting.FileSystemObject").GetFolder(ThisWorkbook.Path).Files
  5.     Set F = CreateObject("Scripting.FileSystemObject").GetFolder("§Aªº¸ê®Æ§¨¸ô®|??").Files
  6.     '.Files ->³o¸ê®Æ§¨¸ô®|¤¤ªº©Ò¦³ªºÀÉ®×
  7.     ReDim AR(1 To 2, 1 To F.Count)
  8.     For Each E In F
  9.         If E Like "*.txt" Then     'ÀÉ®×°ÆÀɦW¬°txt
  10.             i = i + 1
  11.             AR(1, i) = E                        '°}¦C²Ä¤@ºû ¸m¤JÀɮצWºÙ
  12.             AR(2, i) = CDbl(E.DateLastModified) '°}¦C²Ä¤Gºû ¸m¤J¦sÀɪº¤é´Á®É¶¡
  13.         End If
  14.     Next
  15.     A = Application.WorksheetFunction.Index(AR, 2)
  16.     xFile = AR(Application.Match(Application.Max(A), A, 0), 1)  '³Ì·s¦sÀɪºÀɮצWºÙ
  17.     Set F = CreateObject("Scripting.FileSystemObject").OPENTextFile(xFile, 1)   '¶}±Ò¤å¥óÀÉ,Ū¨ú¼Ò¦¡
  18.     A = Split(F.readall, vbLf)         'Ū¨úÀɮפº®e
  19.     F.Close                            'Ãö³¬¤å¥óÀÉ®×
  20.     Set F = CreateObject("Scripting.FileSystemObject").CreateTextFile(xFile, True) '¶}±Ò¤å¥óÀÉ,¥iÂл\­ì¤å¥óÀɼҦ¡
  21.     For i = 0 To UBound(A)
  22.         F.WriteLine IIf(i > 1 And A(i) <> "", Space(1), "") & A(i)
  23.     Next
  24.     F.Close
  25. End Sub
½Æ»s¥N½X
·P®¦ªº¤ß......(¦b³Â»¶®a±Ú°Q½×°Ï.¥Î¤ß¾Ç²ß·|¦³¶i¨Bªº)
¦ý¸ê·½µL­­,«á´©¦³­­,  ¤@¤Ñ1¤¸ªºÃÙ§U,¤H¤H¦³¯à¤O.

TOP

        ÀR«ä¦Û¦b : ¤ß¤¤±`¦sµ½¸Ñ¡B¥]®e¡B·P«ä¡Bª¾¨¬¡B±¤ºÖ¡C
ªð¦^¦Cªí ¤W¤@¥DÃD