Mohsen Ahmadi
asked on
'input past end of file' error while opening some XML files in EXCEL
I have got some VBA codes in an EXCEL file to find and replace some texts in XML files located in a specific directory(please see the attached files). It works well when the XML files are encoded in UTF-8.
The problem is, the files that I need to manipulate are encoded in UCS and I get 'input past end of file' error when I try the code on them.
I appreciate if you could help me to resolve this.
Kind regards,
Mohsen
123.xml
XML-Text-Replace.xlsm
The problem is, the files that I need to manipulate are encoded in UCS and I get 'input past end of file' error when I try the code on them.
I appreciate if you could help me to resolve this.
Kind regards,
Mohsen
123.xml
XML-Text-Replace.xlsm
@Mohsen Ahmadi,
Are you all set with this now, or do you need more help? If all set, could you please close it out now. If you need help with the question close process take a look at:
»bp
Are you all set with this now, or do you need more help? If all set, could you please close it out now. If you need help with the question close process take a look at:
»bp
This question needs an answer!
Become an EE member today
7 DAY FREE TRIALMembers can start a 7-Day Free trial then enjoy unlimited access to the platform.
View membership options
or
Learn why we charge membership fees
We get it - no one likes a content blocker. Take one extra minute and find out why we block content.
You are going to need / want to use the filesystem object for reading and writing the files, it is better at handling different encodings. The following updated procedure works in testing here with that file now.
If you want additional info on the FileSystem here are some links below that should help, it's a good tool to be familiar with. Also, I used it in the code below in "late binding" mode so that you didn't need to add a reference to your project. But when you are first coding with it you probably want to use "early binding" and be able to have the VBA IDE intellisense show the various methods and properties. These two different approaches are mention in the 2nd and 3rd articles below. Hope this helps.
Open in new window
»bp