Thanks for the tip! Works great for medium-sized files. Have you thought about what approach to take for very long files? (you mention in the post that the input is a very long text string) When we hit the macro variable length limit (max 65534 characters), this code seems to drop the first part of the file and only saves the last part of the file in the macro variable.