Reputation: 1
im trying to read from files, which are sometimes opened by users in Excel application and i cant close them. i tried witd ADO Stream object, it gives me error "File could not be opened". when i close the file, it works fine.
Set oTxtStream = CreateObject("ADODB.Stream")
oTxtStream.CharSet = "utf-8"
oTxtStream.Open
Call oTxtStream.LoadFromFile(sMdmTestMetadataResults)
only method i found working is OpenTextFile() from FileSystemObject. but as i studied it, it reads with utf-16, but no utf-8.
Set fso = CreateObject("Scripting.FileSystemObject")
Set file = fso.OpenTextFile("C:\LOCAL\Jonas\resources\xls\MdmTestMetadata.csv", ForReading)
content = file.ReadAll
is there some way to get the file content in utf-8 from opened text files?
tried the methods describer in description
Upvotes: 0
Views: 157
Reputation: 862
ADODB.Stream requires exclusive access to a file. You could try to first copy the open file to a temporary file using fso.CopyFile
. CopyFile does not require exclusive access to a file. Then this temporary file can be read using ADODB.Stream. However, if an open file is copied, there is a risk that the integrity of the data is compromised.
Upvotes: 0