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

[µo°Ý] ¥Îexcel¥´¶}µ§°O¥»

¥»©«³Ì«á¥Ñ register313 ©ó 2012-1-5 17:15 ½s¿è

¦^´_ 9# an13755
¦^´_ 9# GBKEE

GBKEE²Ä¤@ª©
FileFormat:=xlText §ï¬° FileFormat:=xlTextPrinter  (¥tÀxTXTÀÉ §ï¥tÀxPRNÀÉ)
¦ýPRNÀɨC¤@¦C¶W¹L240¦r¤¸(¦n¹³)´N·|¦Û°Ê´«¦æ
  1. Option Explicit
  2. Sub ZZ()
  3.     Dim Rng As Range, i As Integer
  4.     Application.ScreenUpdating = False
  5.     For i = 1 To 50
  6.         ' i ¬O¼Æ¦r        ->Sheets(i)   ¬¡­¶Ã¯µøµ¡¤W²Ä´X­Ó¤u§@ªí
  7.         'i & "" Åܦ¨¦r¦ê  ->Sheets(& "") ¤u§@ªíi
  8.         Set Rng = Sheets(i & "").Range("A1:A20")  'Rng³]©w¬° ¤u§@ªíiªº½d³ò
  9.         With Workbooks.Add(1)                     '·s¼W¬¡­¶Ã¯(¤u§@ªí1±i)
  10.             Rng.Copy .Sheets(1).Cells(1)          '½Æ»s¨ì·s¼W¬¡­¶Ã¯²Ä1 ±i¤u§@ªíªº[A1]
  11.             .SaveAs Filename:="D:\" & i & ".txt", FileFormat:=xlTextPrinter, CreateBackup:=False
  12.             .Close True
  13.     End With
  14.     Next i
  15.     Application.ScreenUpdating = True
  16. End Sub
½Æ»s¥N½X

TOP

g¤j®v±z¦n

±zÀ°¤F¤p¤k¤l1­Ó¤j¦£,Åý§Ú¸`¬Ù¤£¤Ö®É¶¡

ÁٲӤߪº½s¼gµù¸Ñ,«ü¾É±ß½ú

¥Í©R¤¤¦h¤F¨Ç³\ªº®É¶¡¥i¥H¹B¥Î

³£­n·PÁ±zªºÀ°¦£,ÁÂÁÂ!!

ÁÙ¦³r¤j®vl¤j®v¤]·PÁ§A­ÌªºÀ°¦£

r¤j®v³Ì«áªºµ{¦¡¤]¥i¥H,ÁÂÁÂ!!
an

TOP

¤j¤j±z¦n,
§Ú¬Ý¤F³o­Óµoªí·Q¨ì¦Û¤v¦³¤@­ÓÃþ¦üªº°ÝÃD,¤£ª¾¯à§_±µµÛµo°Ý?§Ú¿ý»s¥¨¶°·Q±qexcel sheet("booking")ªºB3:B35½Æ»s¶K¨ìTXTªºµ§°O¥»¤¤,¨Ã¥Hsheet("booking")ªºA1Àx¦s®æ¬°ÀɦW,¦ý¥¨¶°µLªk¿ý»s,¨C¦¸³£¥u¥X²{¥H¤U´X¦æ?¤£ª¾°ÝÃD¥X¦b­þ¸Ì?¥i§_¸Ñ¨M?

Sub copy_to_TXT()
'
' copy_to_TXT ¥¨¶°
'

'
    Cells.Select
    Selection.Copy
End Sub

TOP

¥»©«³Ì«á¥Ñ GBKEE ©ó 2012-1-17 10:10 ½s¿è

¦^´_ 13# PJChen
¸Õ¸Õ¬Ý
  1. Sub Ex()
  2.     Dim Rng(1 To 2) As Range, Fs As Object, A As Object, E As Range
  3.     Application.ScreenUpdating = False
  4.     With Workbooks("test")                       '½Ð§ï¦¨­n½Æ»s¬¡­¶Ã¯ªº¦WºÙ
  5.         Set Rng(1) = .Sheets("booking").[B3:B35]  'Rng(1) ¤u§@ªí­n½Æ»sªº½d³ò
  6.         Set Rng(2) = .Sheets("booking").[A1]      'Rng(2) ¦sÀɦWºÙªºÀx¦s®æ
  7.     End With
  8.     Set Fs = CreateObject("Scripting.FileSystemObject")        'FileSystemObject ª«¥ó ´£¨Ñ¹ï¹q¸£Àɮרt²Îªº¦s¨ú¡C
  9.     Set A = Fs.CreateTextFile("D:\" & Rng(2) & ".txt", True)   '«Ø¥ß¤å¦rÀÉ®×
  10.     'CreateTextFile ¤èªk «Ø¥ß¤@­Ó«ü©wªºÀɦW¨Ã¥B¶Ç¦^¤@­Ó¥Î©ó¸ÓÀÉ®×Ū¼gªº TextStream ª«¥ó¡C
  11.     '¦pªG¥i³QÂл\¨ä­È¬° True¡A¨ä¬° False ®ÉµLªkÂл\
  12.     For Each E In Rng(1)                          '¨Ì§Ç³B¸Ì½Æ»s½d³òªºÀx¦s®æ
  13.         A.WriteLine (E)                           'Àx¦s®æ¼g¤J¤å¦rÀÉ
  14.     Next
  15.     A.Close
  16.     Application.ScreenUpdating = True
  17. End Sub
½Æ»s¥N½X

TOP

GBKEE¤j¤j±z¦n,
§ÚªºÀɮצì¸m¤Î¦WºÙ¦p¤UP:\BCM\2011 Shipping for NE.xlsx©Ò¥H§Ú§â¥¦§ï¦¨   With Windows("P:\BCM\2011 Shipping for NE.xlsx\ Workbooks(Booking") ,°õ¦æ¨ì²Ä04¦æ¥X¤F°ÝÃD,¥i¥HÀ°§Ú¬Ý¬Ý­þ¸Ì§ï¿ù¤F¶Ü?

TOP

¦^´_ 15# PJChen
With Workbooks("test")        '½Ð§ï¦¨­n½Æ»s¬¡­¶Ã¯ªº¦WºÙ   
³oÀɮפw¸g¶}±Ò           With Workbooks("2011 Shipping for NE.xlsx")
³oÀɮש|¥¼¸g¶}±Ò       With Workbooks.Open("P:\BCM\2011 Shipping for NE.xlsx")

TOP

¤£¦n·N«ä,°õ¦æÁÙ¬O¦³°ÝÃD,½Ð¤j®vÀ°¦£¬Ý¬Ý:
    Dim Rng(1 To 2) As Range, Fs As Object, A As Object, E As Range
    Application.ScreenUpdating = False
    With Workbooks("2011 Shipping for NE.xlsx")  '½Ð§ï¦¨­n½Æ»s¬¡­¶Ã¯ªº¦WºÙ(¤w¸g¥´¶})
        Set Rng(1) = .Sheet("Booking").[B3:B35]   '³o¸Ì´N°õ¦æ¤£¤U¤F
        Set Rng(2) = .Sheet("Booking").[A1]      'Rng(2) ¦sÀɦWºÙªºÀx¦s®æ
    End With
    Set Fs = CreateObject("Scripting.FileSystemObject")        'FileSystemObject ª«¥ó ´£¨Ñ¹ï¹q¸£Àɮרt²Îªº¦s¨ú¡C
    Set A = Fs.CreateTextFile("P:\BCM\Shipping Doc\PJ\HK Packing\" & Rng(2) & ".txt", True)   '«Ø¥ß¤å¦rÀÉ®×
    'CreateTextFile ¤èªk «Ø¥ß¤@­Ó«ü©wªºÀɦW¨Ã¥B¶Ç¦^¤@­Ó¥Î©ó¸ÓÀÉ®×Ū¼gªº TextStream ª«¥ó¡C
    '¦pªG¥i³QÂл\¨ä­È¬° True¡A¨ä¬° False ®ÉµLªkÂл\
    For Each E In Rng(1)                          '¨Ì§Ç³B¸Ì½Æ»s½d³òªºÀx¦s®æ
        A.WriteLine (E)                           'Àx¦s®æ¼g¤J¤å¦rÀÉ
    Next
    A.Close
    Application.ScreenUpdating = True

TOP

¥»©«³Ì«á¥Ñ GBKEE ©ó 2012-1-17 10:12 ½s¿è

¦^´_ 17# PJChen
14# ¦³¿ù ¤w§ó¥¿¬°
Set Rng(1) = .SheetS("Booking").[B3:B35]

TOP

¤j®v±z¦n,
    For Each E In Rng(1)
        A.WriteLine (E)                           '°õ¦æ¨ì³o¸Ì´N°±¤F,½ÐÀ°À°§Ú
    Next
    A.Close
    Application.ScreenUpdating = True
   
End Sub

TOP

¦^´_ 19# PJChen
¶Ç¤WÀɮ׬ݬÝ

TOP

        ÀR«ä¦Û¦b : ½_ÁJµ²±o¶V¹¡º¡¡A¶V·|©¹¤U««¡A¤@­Ó¤H¶V¦³¦¨´N¡A´N­n¶V¦³Á¾¨Rªº¯ÝÃÌ¡C
ªð¦^¦Cªí ¤W¤@¥DÃD