+ Reply to Thread
Results 1 to 6 of 6

OPEN TEXT then WRITE TEXT Unicode incorrect

  1. #1
    Forum Expert JBeaucaire's Avatar
    Join Date
    03-21-2004
    Location
    Bakersfield, CA
    MS-Off Ver
    2010, 2016, Office 365
    Posts
    33,492

    OPEN TEXT then WRITE TEXT Unicode incorrect

    In a nutshell, I am using the OPEN FOR OUPUT method to create a text file, then I'm reading another text file line by line and only adding lines to the new file if it does not have any of the exclusion text strings in it.l

    Then I write out the new file.

    The problem is that 7 out of 10 files created this way end up looking like chinese characaters when I open them in a text editor. I have to manually set the text file encoding to UTF-8, it appears that a huge portion of them are ending up UTF-16 encoding.

    So, how do write out the final file from within VBA forcing the UTF-8? Googling is coming up with difficult answers.

    Abridged:
    Please Login or Register  to view this content.
    Are those some Print options I'm not aware of to insure the resulting text file is forced to be UTF-8?
    _________________
    Microsoft MVP 2010 - Excel
    Visit: Jerry Beaucaire's Excel Files & Macros

    If you've been given good help, use the icon below to give reputation feedback, it is appreciated.
    Always put your code between code tags. [CODE] your code here [/CODE]

    ?None of us is as good as all of us? - Ray Kroc
    ?Actually, I *am* a rocket scientist.? - JB (little ones count!)

  2. #2
    Forum Guru MarvinP's Avatar
    Join Date
    07-23-2010
    Location
    Woodinville, WA
    MS-Off Ver
    Office 365
    Posts
    16,169

    Re: OPEN TEXT then WRITE TEXT Unicode incorrect

    Hey Jerry,

    This sounds like a Power Query problem to me. When you open the file, there are lots of options to import the data. See all the options:
    https://docs.microsoft.com/en-us/pow...p-data-sources

    Filtering out rows that contain strings is also easy using PQ using Text Filter of Contains.

    Have you tried your data in PQ yet?
    One test is worth a thousand opinions.
    Click the * Add Reputation below to say thanks.

  3. #3
    Forum Expert JBeaucaire's Avatar
    Join Date
    03-21-2004
    Location
    Bakersfield, CA
    MS-Off Ver
    2010, 2016, Office 365
    Posts
    33,492

    Re: OPEN TEXT then WRITE TEXT Unicode incorrect

    Zero exp with that. I was really hoping to not toss 100s of lines of coding for a whole new macro....

  4. #4
    Forum Expert mike7952's Avatar
    Join Date
    12-17-2011
    Location
    Florida
    MS-Off Ver
    Excel 2007, Excel 2016
    Posts
    3,520

    Re: OPEN TEXT then WRITE TEXT Unicode incorrect

    Adodb

    Have you looked Here
    Thanks,
    Mike

    If you are satisfied with the solution(s) provided, please mark your thread as Solved.
    Select Thread Tools-> Mark thread as Solved.

  5. #5
    Forum Expert shg's Avatar
    Join Date
    06-20-2007
    Location
    The Great State of Texas
    MS-Off Ver
    2003, 2010
    Posts
    40,678

    Re: OPEN TEXT then WRITE TEXT Unicode incorrect

    I have this off the shelf, JB, and I'm off to bed.

    Please Login or Register  to view this content.
    Entia non sunt multiplicanda sine necessitate

  6. #6
    Forum Expert JBeaucaire's Avatar
    Join Date
    03-21-2004
    Location
    Bakersfield, CA
    MS-Off Ver
    2010, 2016, Office 365
    Posts
    33,492

    Re: OPEN TEXT then WRITE TEXT Unicode incorrect

    Thanks guys, this is what I needed, a little good-old-fashioned-handholding. Cheers!

+ Reply to Thread

Thread Information

Users Browsing this Thread

There are currently 1 users browsing this thread. (0 members and 1 guests)

Similar Threads

  1. [SOLVED] Copy DDMMYYYYHHMMSS and Paste as Unicode Text
    By adriles in forum Excel Programming / VBA / Macros
    Replies: 1
    Last Post: 12-05-2014, 07:53 AM
  2. How to import Unicode text file in VBA ?
    By allan.riegel in forum Excel Programming / VBA / Macros
    Replies: 2
    Last Post: 05-14-2014, 03:28 AM
  3. Change unicode text format
    By CAS123 in forum Excel General
    Replies: 0
    Last Post: 11-13-2012, 09:10 AM
  4. Excel-Paste Special - Unicode Text [IE8 vs Firefox]
    By windunce in forum Excel General
    Replies: 2
    Last Post: 03-09-2010, 03:36 PM
  5. Replies: 1
    Last Post: 01-12-2009, 03:05 AM
  6. on open, write to text file?
    By aceee in forum Excel Programming / VBA / Macros
    Replies: 3
    Last Post: 04-07-2008, 10:44 PM

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts

Search Engine Friendly URLs by vBSEO 3.6.0 RC 1