내가 텍스트 파일에 쉼표로 모든 탭을 교체하려면 다음 코드를 사용하려고 다음 file 부착이 실행 그러나유니 코드 TXT 파일로 작업하지 스크립트를 교체
Const ForReading = 1
Const ForWriting = 2
Const TristateTrue = -1
Set objFSO = CreateObject("Scripting.FileSystemObject")
Set objFile = objFSO.OpenTextFile("C:\Users\Tom\Desktop\CSV.txt", ForReading, TristateTrue)
strText = objFile.ReadAll
strTab = vbTab
strText = Replace(strText, strTab, ",")
objFile.Close
Set objFile = objFSO.OpenTextFile("C:\Users\Tom\Desktop\CSV.txt", ForWriting, TristateTrue)
objFile.Write strText
objFile.Close
, 내가 얻을 오류 :
라인 (17) 샤아 1 잘못된 프로 시저 호출 또는 인수
이 파일은 엑셀에서 만든 유니 코드 TXT 파일입니다.
파일을 열고 UTF-8 형식으로 저장하면 코드가 올바르게 작동합니다. 그러나, 나는 깨진 결과없이 코드에서이 변환을 할 수있는 방법을 찾을 수 없다.
누구든지 내 코드를 원래 유니 코드 텍스트 파일로 작업하거나 실행 코드 (vba/배치)를 사용하여 UTF-8로 파일을 변환하는 방법을 찾을 수 있습니까? 도움말
Opens a specified file and returns a TextStream object that can be used to read from, write to, or append to the file.
object.OpenTextFile(filename[, iomode[, create[, format]]])
object
Required. Object is always the name of a FileSystemObject.
filename
Required. String expression that identifies the file to open.
iomode
Optional. Can be one of three constants: ForReading, ForWriting, or ForAppending.
create
Optional. Boolean value that indicates whether a new file can be created if the specified filename doesn't exist. The value is True if a new file is created, False if it isn't created. If omitted, a new file isn't created.
format
Optional. One of three Tristate values used to indicate the format of the opened file. If omitted, the file is opened as ASCII.
에서
와우 나는 그것을 놓쳤습니다. 고마워요! 나는 TristateTrue가 Create에 대해 그것이 부울이 아니므로 오류를 일으켰을 것이라고 생각했을 것입니까? 아무리해도 완벽하게 작동합니다! – Tom