+ Reply to Thread
Results 1 to 11 of 11

Saving UTF-8

  1. #1
    Registered User
    Join Date
    01-18-2011
    Location
    Ramat Hasharon, Israel
    MS-Off Ver
    Excel 2010
    Posts
    16

    Question Saving UTF-8

    Is there a way in VBAscript to CreateTextFile in UTF-8, or convert a file to UTF-8?
    I am using Excel 2010
    Last edited by efratnakash; 01-23-2011 at 05:35 AM.

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

    Re: Saving UTF-8

    Maybe something along the lines of:

    Please Login or Register  to view this content.
    _________________
    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!)

  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: Saving UTF-8

    A Google search led to posts that implied saving your workbook in CSV format will suffice as well.
    Quote Originally Posted by xenou
    Excel CSV files are normally fine in any situation where UTF-8 encoding is needed - I've never encountered a problem (knock on wood).

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

    Re: Saving UTF-8

    A macro said to accomplish the same task:
    http://josephtbradley.wordpress.com/...th-no-orphans/

  5. #5
    Registered User
    Join Date
    01-18-2011
    Location
    Ramat Hasharon, Israel
    MS-Off Ver
    Excel 2010
    Posts
    16

    Re: Saving UTF-8

    @JBeaucaire: thank you for all your replies, and the link.

    I am trying to figure out how to implement it.

    Currently I create and open a file, and write line after line (from the sheet data). The name of the output file is sitemap.xml.

    I was hoping I could elegantly create a UTF-8 file (means write down the file in UTF-8, as you hinted in your first replies).

    Using the function in the link you provided, I understand I should convert the created Unicode file to UTF-8.

    If it is not too much to ask, would you please be so kind and update the procedure so it will take full-path-sitemap.xml as an input file, convert and overwrite it as UTF-8?

    Many thanks

  6. #6
    Registered User
    Join Date
    01-18-2011
    Location
    Ramat Hasharon, Israel
    MS-Off Ver
    Excel 2010
    Posts
    16

    Re: Saving UTF-8

    I think I figured out how to implement the code, but get a Compile error: Object required

    The fsT= is highlighted in the second line:

    Please Login or Register  to view this content.
    What might be wrong?
    Last edited by efratnakash; 01-22-2011 at 02:05 PM.

  7. #7
    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: Saving UTF-8

    Please Login or Register  to view this content.
    Please take a few minutes to read the forum rules, and then edit your post to add CODE tags.

    Thanks.
    Entia non sunt multiplicanda sine necessitate

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

    Re: Saving UTF-8

    You don't "set" strings. The fsT variable is DIM'd incorrectly. Take off the "As String" after it...probably should be an object.

    (EDIT: hat-tip to shg, that's the ticket)

  9. #9
    Registered User
    Join Date
    01-18-2011
    Location
    Ramat Hasharon, Israel
    MS-Off Ver
    Excel 2010
    Posts
    16

    Re: Saving UTF-8

    For:
    Please Login or Register  to view this content.
    I get the following error message: Run-time error ‘424’: Object required

    Same error when I remove "As String" and stay with
    Please Login or Register  to view this content.
    Last edited by efratnakash; 01-22-2011 at 02:07 PM.

  10. #10
    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: Saving UTF-8

    This writes a string to a UTF-8 file.
    Please Login or Register  to view this content.

  11. #11
    Registered User
    Join Date
    01-18-2011
    Location
    Ramat Hasharon, Israel
    MS-Off Ver
    Excel 2010
    Posts
    16

    Re: Saving UTF-8

    It worked!

    Thank you sssoooo much!

+ Reply to Thread

Thread Information

Users Browsing this Thread

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

Tags for this Thread

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