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

[µo°Ý] ÀÉ®×¾Þ§@ºÃ°Ý½Ð±Ð

[µo°Ý] ÀÉ®×¾Þ§@ºÃ°Ý½Ð±Ð

¦b¾Þ§@Àɮ׮ɤ@ª½­«ÂЦb²Ä¤@­ÓcsvÀɾާ@

µLªk¸õ¨ì¤U¤@­ÓcsvÀÉ®×

½Ð°Ý°ª¤â¤U­±ªºµ{§Ç¨ì©³­þ¸Ì¥X¤F°ÝÃD

«ç»ò¦n¹³°­¥´Àð¤@ª½¦b­ì¦a¶ ÁÂÁÂ

Sub Test()

On Error Resume Next

Application.DisplayAlerts = False

bPath = ThisWorkbook.Path

If Right(bPath, 1) <> "\" Then dirpath = bPath & "\"

csvName = Dir(dirpath & "*.csv")

Do While Len(csvName) > 0

    MsgBox csvName
   
    Workbooks.Open (dirpath & csvName)
    '
    'balabalabala
    '
    '
    ActiveWorkbook.Close savechanges:=False
            
    csvName = Dir
   
Loop

End Sub

¦^´_ 11# luhpro


­ì¨ÓÁÙ¦³°Ï°ìÅܼƪº¦]¯À

ÁöµM§Úªº°ÝÃD¤w¸g¸Ñ¨M

¦ý¦A¸Õ¸Õ¨ì©³¬O­þ­ÓÅܼƥX°ÝÃD

¦A¨Ó´£°Ý ÁÂÁ¦U¦ìªº¦^µª

TOP

¥»©«³Ì«á¥Ñ luhpro ©ó 2010-9-8 00:39 ½s¿è

¦^´_ 9# huang40

¤j­P¤W¬Ý¤F¤@¤U¨â­Ó Sub ªº®t²§«á,
§Úı±o³Ì¤j¥i¯à¥X°ÝÃDªº­ì¦]¦b©ó "°Ï°ìÅܼÆ",
§A¥i¥H¸ÕµÛ¦b©I¥s¥Dµ{¦¡«e±N¡@csvName Àx¦s¨ì¬Y­ÓÀx¦s®æ¤º,
©óµ{§Çªð¦^«á¦A¥ß§YÁÙ­ì¦^¥h¸Õ¸Õ¬Ý.

¦b§Úªº¸gÅ礤 Excel VBA ¸Ì¦³®É­Ô¨ä°Ï°ìÅܼƤº®e¬O·|»P§Ú­Ìªº¹w´Á­È¤£¦Pªº,
¤×¨ä¬O¦³©I¥s¨ì¬Y¨Çªºµ{§Ç©Î¤èªk®É.

TOP

¥»©«³Ì«á¥Ñ Hsieh ©ó 2010-9-7 18:02 ½s¿è

¦^´_ 9# huang40

­n¾Ç²ßVBA´N­n¾Ç·|°»¿ù
³v¦æ(F8)
¤@¦æ¤@¦æ¶]µ{¦¡¬ÝÅܼƭȪºÅܤƧä¥X¿ù»~
¾Ç®üµL²P_¤£®¢¤U°Ý

TOP

¥»©«³Ì«á¥Ñ huang40 ©ó 2010-9-7 11:39 ½s¿è

¨ä¹ê°ÝÃD«Ü³æ¯Â(©ÎªÌ§Ú¦Û¥H¬°«Ü³æ¯Â)

¦bTEST1¤£¯à°õ¦æªº¥Dµ{¦¡¥h«o¦bTEST2¥i¥H°õ¦æ

¨º°ÝÃD·|¬O¥X¦b­þ©O

Sub Test1()
Application.DisplayAlerts = False
dirPath = ThisWorkbook.Path & "\"
csvName = Dir(dirPath & "*.csv")
Do While csvName <> ""
    Workbooks.Open (dirPath & csvName)
    '
    '(¥Dµ{¦¡)
    '
    ActiveWorkbook.Close savechanges:=False            
    csvName = Dir
Loop

Sub Test2()
Application.DisplayAlerts = False
Sheets(1).Activate
Columns("V").Clear
dirPath = ThisWorkbook.Path & "\"
csvName = Dir(dirPath & "*.csv")
n = 0
Do While csvName <> ""
    n = n + 1  
    Cells(n, 22) = csvName               
    csvName = Dir   
Loop
MsgBox "ÀÉ®×¼Æ=" & n
For i = 1 To n
csvfile = Sheets(1).Cells(i, 22)
Workbooks.Open (dirPath & csvfile)   
    '
    '(¥Dµ{¦¡)
    '
ActiveWorkbook.Close savechanges:=False
next i
End Sub

TOP

³o»ò»¡§O¤HµLªkª¾¹D¿ù»~®ÉÅã¥Ü¤°»ò¤Î¥X¿ù®É¬Û¹ïÅܼƪº­È¬O§_¥¿½T¡A¥u¦³§A¦Û¤v¤@¦æ¦ærun®É¤~·|ª¾¹Dªº¡I

TOP

¥»©«³Ì«á¥Ñ huang40 ©ó 2010-9-6 20:06 ½s¿è

¸Õ¹LÁÙ¬O¥d¦bcsvName=dir³o¸Ì

¨Sªk¥i·Q¥u¦n¥Î³Ì²Âªº¤èªk

¥ý§âÀɦW¦C¥X¦A¤@­Ó¤@­Ó¶}±Ò ²×©ó·d©w

¥i¬O¹ï¬°¤°»ò·|¥d¦b csvName=dir ÁÙ¬O¤£ÁA

Á`¦³­Ó²z¥Ñ§a

Sub Test()
Application.DisplayAlerts = False
Sheets("MK").Activate
Columns("V").Clear
bPath = ThisWorkbook.Path
dirPath = ThisWorkbook.Path & "\"
csvName = Dir(dirPath & "*.csv")
n = 0
Do While csvName <> ""
    n = n + 1  
    Cells(n, 22) = csvName               
    csvName = Dir   
Loop
MsgBox n
For i = 1 To n
csvfile = Sheets(1).Cells(i, 22)
Workbooks.Open (dirPath & csvfile)    '
    '
    'balabalabala
    '
ActiveWorkbook.Close savechanges:=False
next i

TOP

¦^´_ 5# huang40
¨º´NºCºC³v¦æ°»¿ù¡A¬Ý¿ù»~¥X¦b­þ?
¾Ç®üµL²P_¤£®¢¤U°Ý

TOP

¥»©«³Ì«á¥Ñ huang40 ©ó 2010-9-6 11:30 ½s¿è

¦^´_ 4# Hsieh


³o¼Ë¬O°õ¦æOK

¦ý¤@¥¹¥[¤J¤¤¶¡balabalabalaªº³B²zµ{§Ç

  Workbooks.Open (dirPath & csvName)
    '
    'balabalabala
    '
    '
    ActiveWorkbook.Close savechanges:=False

csvName=dir ³o¦æ´NÁÙ¬O¥X²{¿ù»~°T®§

¦³¥i¯à¦]¬°¤¤¶¡³B²zªºµ{§Ç½X¥X°ÝÃD¾É­P¶Ü?

TOP

¦^´_ 3# huang40


    Sub Test()


Application.DisplayAlerts = False

dirPath = ThisWorkbook.Path & "\"

csvName = Dir(dirPath & "*.csv")

Do While csvName <> ""

    MsgBox csvName
   
    Workbooks.Open (dirPath & csvName)
    '
    'balabalabala
    '
    '
    ActiveWorkbook.Close savechanges:=False
            
    csvName = Dir
   
Loop

End Sub
¾Ç®üµL²P_¤£®¢¤U°Ý

TOP

        ÀR«ä¦Û¦b : ¨C¤ÑµL©Ò¨Æ¨Æ¡A¬O¤H¥Íªº®ø¶OªÌ¡A¿n·¥¡B¦³¥Î¤~¬O¤H¥Íªº³Ð³yªÌ¡C
ªð¦^¦Cªí ¤W¤@¥DÃD