Share via

Excel vba output using vbUnicode

Anonymous
2015-08-03T16:15:44+00:00

My son wrote a vba that creates a text string and then outputs it to a Unicode file.  His output line is...

Print #2, StrConv (NewFile, vbUnicode)

It creates the new file okay except the file should begin with FF FE.  The new file begins with FF 00 FE 00.

How do I go about fixing this? Thanks.

Microsoft 365 and Office | Excel | For home | Windows

Locked Question. This question was migrated from the Microsoft Support Community. You can vote on whether it's helpful, but you can't add comments or replies or follow the question.

0 comments No comments

3 answers

Sort by: Most helpful
  1. Anonymous
    2015-08-04T14:53:39+00:00

    My take on that is using Print causing the problem. Instead you should use the FileSystemObject approach to create/open the file and write out unicode text

    Was this answer helpful?

    0 comments No comments
  2. Anonymous
    2015-08-04T14:45:35+00:00

    Thanks for replying. It seems that the stackoverflow was talking about making changes to a file's title, whereas I'm trying to have Excel write the first two bytes in a unicode file as FF EE and not FF 00 FE 00.

    A unicode file's first two bytes tell what type of file it is... and FF FE is a Unicode UTF-16 Little Endian file. I'm not an expert by any means... just trying to get my son's code working properly.

    After the file is written by Excel, I have to load it into Notepad and delete the first 2 characters that show up at the start of the file, and then save it. This removes the FF 00 FE 00 and replaces them with FF FE.

    Was this answer helpful?

    0 comments No comments
  3. Anonymous
    2015-08-04T12:28:42+00:00

    See the replies in this stackoverflow question about vba files and unicode

    output unicode

    Was this answer helpful?

    0 comments No comments