iT邦幫忙

0

VBA 文字輸入TXT檔案之編碼問題

  • 分享至 

  • xImage

各位先進,小妹需要將TXT檔案的某些文字取代成另一個
寫了以下程式後雖然可以順利輸出,但卻發現編碼為"ANSI",但我需要為"UTF-8"的編碼
研究了好久,還是不知道該怎麼修改,因此上來請教...
程式如下

Dim f As String
Dim d As String

f = "C:\Users\新增資料夾\011.txt"
d = "C:\Users\新增資料夾\222.txt"

Open f For Input As #1
Open d For Output As #2
 
    Do Until EOF(1)
        
        Line Input #1, LineFromFile
        
        If lineformfile = Range("A1") Then
            Print #2, Range("B1")
        Else
            Print #2, LineFromFile
        End If
        
    Loop

Close #1
Close #2
harry731 iT邦新手 3 級 ‧ 2024-01-19 07:59:36 檢舉
可以參考此篇
https://ithelp.ithome.com.tw/questions/10202358?sc=pt
wd_811 iT邦新手 5 級 ‧ 2024-01-19 13:45:19 檢舉
謝謝幫忙,已解決問題了。
圖片
  直播研討會
圖片
{{ item.channelVendor }} {{ item.webinarstarted }} |
{{ formatDate(item.duration) }}
直播中

尚未有邦友回答

立即登入回答