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

[Âà¶K] VBA-§å¦¸´¡¤J¦h­Ó¤å¦rÀÉ

[Âà¶K] VBA-§å¦¸´¡¤J¦h­Ó¤å¦rÀÉ

­ìµoªíªÌ¡Gleonchou (2005-04-18)

³o¬Oºô¤Í´¿°Ý§Úªº°ÝÃD¡G¡@
¦³100­Ó¤å¦rÀÉ (ÀɦW³£¤£¤@¼Ë)¡A·Q­n´¡¤J¤å³¹¤§¤¤¡A¦ý¬O Wordªº´¡¤JÀÉ®×¥\¯à¡A¨C¦¸¥u¯à´¡¤J¤@­ÓÀɮסA¤£ª¾¬O§_¥i¥H¤@¦¸´N±N©Ò¦³ªºÀÉ®×´¡¤J??
§Ú§ä¨Ó§ä¥h, Word ¦ü¥G¯uªº¨S¦³¤@¦¸´¡¤J¦h­ÓÀɮתº¥\¯à~
¥u¦n¥Î¥¨¶°¨Ó°µ¤F...
¡@
½Ð·s¼W¨Ã°õ¦æ¥H¤U³o­Ó¥¨¶°¡A¥¦·|¸ß°ÝÀɮצs©ñªº¸ô®|¡AµM«á¦Û°Ê±N¸Ó¥Ø¿ý¤U©Ò¦³¯Â¤å¦rÀÉ (*.txt) ´¡¤J¥Ø«e¤å¥ó¸Ì¡C
³o­Ó¨Ò¤l¤]¥Ü½d¤F§å¦¸³B²zÀɮתº°ò¥»¤è¦¡ (Dir)¡C
PS. µ{¦¡¦æ¸¹¦b¦¹¶È¨Ñ»¡©ú¡A¤@¯ë¨Ã«D¥²­n¡C
¡@
Sub ´¡¤J¤å¦rÀÉ()
1 mypath = Options.DefaultFilePath(wdDocumentsPath)
2 mypath = InputBox("½Ð¿é¤J¸ô®|¦WºÙ (¨Ò¦p C:\Temp)¡G", "´¡¤J¤å¦rÀÉ", mypath)
3 If mypath = "" Then Exit Sub Else On Error GoTo Z
4 If Right(mypath, 1) <> "\" Then mypath = mypath & "\"
5 myfile = Dir(mypath & "*.txt", vbDirectory)
6 While myfile <> ""
7 ¡@Selection.InsertFile mypath & myfile
8 ¡@myfile = Dir()
9 Wend
Z
End Sub
¡@
¡e¨Ìµ{¦¡¦æ¸¹»¡©ú¡f¡@
1 ³]©wÅÜ¼Æ mypath = Word ¹w³]ªº¤å¥óÀx¦s¸ô®|.
2 ³]©wÅÜ¼Æ mypath = ¿é¤J¤è¶ô (¹w³]¬° mypath) ªº¦^¶Çµ²ªG.
3 ­Y¦b¿é¤JªÅ¥Õ©Î«ö¤F¨ú®ø, ¶Ç¦^ªÅ¦r¦ê, «hµ²§ô¥¨¶°;§_«h³]©w¥H¤Uµ{¦¡¥X²{¿ù»~®É, ¸õ¨ì Z ¦æ
4 ¦] mypath ¥Nªí¤@­Ó¸ô®|, ­Y¥¦ªºµ²§À¤£¬O \ ²Å¸¹, «h¸É¤W.
5 ³]©wÅÜ¼Æ myfile = ¦b mypath ¸ô®|¤U·j´M©Ò¦³ txt ÀÉ©Ò±o¨ìªº²Ä¤@­ÓÀɦW¡C
6 °õ¦æ°j°é, ª½¨ì¸Ó¸ô®|¤Uªº txt ÀɳB²z§¹²¦¬°¤î.
7 ¦b½s¿è´¡¤JÂI´¡¤JÀÉ®×.
8 ±NÅÜ¼Æ myfile ³]¬°¤U¤@­Ó§ä¨ìªº txt ÀÉ.
9 µ²§ô While...Wend °j°é.
Z ¤£°µ¥ô¦ó°Ê§@, ¥u¨Ñµo¥ÍÀɮצs¨ú¿ù»~®É¸õ¦Ü¦¹³B (µ¥©óµ²§ôµ{¦¡)
°¶Ôйq¤l®Ñ,Åwªï§K¶O¤U¸ü°Ñ¦Ò
http://www.twbts.com/ebook/?subject=office
http://www.twbts.com/ebook/?subject=soft
°¶ÔÐÂîѮw---https://www.facebook.com/groups/669579416484096/
¦³¤@®a¬a¥J©±---https://www.facebook.com/sadodona

        ÀR«ä¦Û¦b : ¤f»¡¤@¥y¦n¸Ü¡A¦p¤f¥X½¬ªá¡F¤f»¡¤@¥yÃa¸Ü¦p¤f¦R¬r³D¡C
ªð¦^¦Cªí ¤W¤@¥DÃD