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

sheetÂàutf8 TXT °ÝÃD

sheetÂàutf8 TXT °ÝÃD

¦U¦ì¤j­ô¦n¡G
¤p§ÌªºTEST.XLS·QÂà¥X UTF8 TEST.TXT¦ý¬O¤@ª½µLªk§JªA¡A
§Ú·Q¥Î²Ä¤@­Ó¥¨¶°§¹¦¨¤£ª¾¬O§_¥i¦æ¡C TEST.rar (12.79 KB)
lionliu

¥»©«³Ì«á¥Ñ lionliu ©ó 2016-1-15 14:26 ½s¿è

ÁÂÁ¨â¦ì¤j­ôªº¨ó§U
§Ú¤w§ä¨ì³B²z¤è¦¡¡AÁÂÁ¡C
¦b¦¹§Ú±N¥¦´£¨Ñ¤j®a°Ñ¦Ò¡G
  1. Sub FileZM(sFile As String, sCode As String, dFile As String, dCode As String)
  2. Dim objStream As Object
  3.     Set objStream = CreateObject("Adodb.Stream")
  4.     With objStream
  5.         .Mode = 3         'adModeReadWrite = 3 ' «ü¥Ü读/写权­­¡C
  6.         .Type = 1         'adTypeBinary = 1
  7.         .Open
  8.         .LoadFromFile sFile   
  9.         .Position = 0
  10.         .Type = 2      
  11.         .Charset = sCode

  12. sCode = .ReadText   
  13.        .Position = 0     
  14.        .SetEOS
  15.        .Type = 2      
  16.        .Charset = dCode   
  17.        .WriteText sCode   
  18.        .SaveToFile dFile, 2
  19.        .Close
  20.       End With
  21. Set objStream = Nothing
  22. End Sub

  23. Sub SAVE_TXT()
  24.     Dim I%, x%, y%, arr, FileName$
  25.     FileName = "D:\TEST\1000724.txt"
  26.     Open FileName For Output As #1
  27.     Do While Sheets(1).Cells(I + 1, "A") <> ""
  28.         Print #1, Sheets(1).Cells(I + 1, "A")
  29.         I = I + 1
  30.     Loop
  31.     Close #1
  32.    §Ú­ì¨Ó²Ä¤@­Ó¥¨¶°©I¥sfileZM³B¸Ì¬J¥i¡C
  33.    Call FileZM(FileName, "big5", FileName, "utf-8")
  34.    
  35. End Sub
½Æ»s¥N½X
¥H¤W¬O§Ú¦b¤j³°ºô¯¸©Ò§ä¨ìªº¸ê®Æ¡A§Ú­×§ï«á´N¯à¨Ï¥Î¤F
¥H¤U¬O§Ú¬Ý¨ìªº¥t¤@ºØ°µªk¤@¨Ö´£¨Ñ¡G¦ý¬O¤£²Å¦X§Úªº»Ý¨D¡C
¥L·|±N©Ò¦³¸ê®Æ¼g¤J¦P¤@¦æ¡A½Ð°Ý¬O§_¦³¤èªk¥i¥HÅý¥L¤@¦C¤@¦æ¡C
¦ý¤å¦r·í¤¤¤£­n¦³ÁôÂ꺧é¦æ²Å¸¹¡C

Sub Day15_4_()
'¦h°ê»y¨¥¤å¦r¼g¤JUTF8®æ¦¡ªº¤å¦rÀÉ
      Sheets(1).Select
      Dim Rng As Object
      Dim strData

      For Each Rng In Range("A1:b9")
          If Rng.Column = 1 Then
              strData = strData & Rng & vbTab
         ElseIf Rng.Column = 2 Then
             strData = strData & Rng & vbCr
         End If
     Next
     Debug.Print strData

     Dim fsT As Object
     Set fsT = CreateObject("ADODB.Stream")
     fsT.Type = 2 '«ü©wÃþ«¬¡AÀx¦s¤å¦r¸ê®Æ¨Ï¥Î2
     fsT.Charset = "UTF-8" '«ü©w¦r¤¸¶°¬°UTF8
     fsT.Open '¶}±Ò»P¼g¤J¤G¶i¦ì¸ê®Æ¨ìª«¥ó
     fsT.WriteText strData
     fsT.SaveToFile "D:\Day15_4_2.txt", 2 '¼g¤J¤G¶i¦ì¸ê®Æ¨ìºÏºÐ
End Sub
¦¹ºØ¼gªk¬O§Úı±o³Ì²«Kªº¡A½Ð°Ý¬O§_¦³¤j­ô¥i¥H«ü¾É­×¥¿¡C
lionliu

TOP

¦^´_ 6# Joforn

ÁÂÁ J¤jªº«ü¾É¡A#3ªº³¡¤À§Ú·|¦A¦n¦nª¦¤@¤U¤å¡C
lionliu

TOP

¦^´_ 6# Joforn
joforn ¤j­ô¦n¡G
§Ú¸Õ¤F§Ú§ä¨ìªº¤èªk¡AÁÙ¦³§Aªº¤èªk¥i¥H²£¥Íutf8¡A¦ý¬O¹ï¤è­n¨D­n¨S¦³BomÀÉ­ºªºutf8¡A
¤£ª¾¤j­ô©Î¨ä¥L¤j¤j¦³µL¨ä¥L¤èªk¡C
lionliu

TOP

¦^´_  Joforn
joforn ¤j­ô¦n¡G
§Ú¸Õ¤F§Ú§ä¨ìªº¤èªk¡AÁÙ¦³§Aªº¤èªk¥i¥H²£¥Íutf8¡A¦ý¬O¹ï¤è­n¨D­n¨S¦³BomÀÉ ...
lionliu µoªí©ó 2016-1-30 08:53

§Ú¸Õ¤F
  1. Sub Day15_4_()
  2. '¦h°ê»y¨¥¤å¦r¼g¤JUTF8®æ¦¡ªº¤å¦rÀÉ
  3.       Sheets(1).Select
  4.       Dim Rng As Object
  5.       Dim strData

  6.       For Each Rng In Range("A1:b9")
  7.           If Rng.Column = 1 Then
  8.               strData = strData & Rng & vbTab
  9.          ElseIf Rng.Column = 2 Then
  10.              strData = strData & Rng & vbCr
  11.          End If
  12.      Next
  13.      Debug.Print strData

  14.      Dim fsT As Object
  15.      Set fsT = CreateObject("ADODB.Stream")
  16.      fsT.Type = 2 '«ü©wÃþ«¬¡AÀx¦s¤å¦r¸ê®Æ¨Ï¥Î2
  17.      fsT.Charset = "UTF-8" '«ü©w¦r¤¸¶°¬°UTF8
  18.      fsT.Open '¶}±Ò»P¼g¤J¤G¶i¦ì¸ê®Æ¨ìª«¥ó
  19.      fsT.WriteText strData
  20.      fsT.SaveToFile "D:\Day15_4_2.txt", 2 '¼g¤J¤G¶i¦ì¸ê®Æ¨ìºÏºÐ
  21. End Sub
½Æ»s¥N½X
³o¤èªk¬OµLbomÀÉ­ºªº¡A¦ý¬O§Ú­n¦p¦ó±N¾ã­Ó¤u§@ªí¨Ì¶¶§Ç¼g¤J¦Ó¤£¬O¦X¦¨¤@¦æ¡A¬O§_¦³¤j­ô¥i¥H«ü¾É¤@¤U¡C
lionliu

TOP

        ÀR«ä¦Û¦b : ¥Í®ð¡A´N¬O®³§O¤Hªº¹L¿ù¨ÓÃg»@¦Û¤v¡C
ªð¦^¦Cªí ¤W¤@¥DÃD