Vba to save and open excel file as UTF - 8

Anaya Zeeshan

New Member
Joined
Nov 4, 2021
Messages
13
Office Version
  1. 365
Platform
  1. Windows
I have a project in which I need to save file as utf - 8 and I am having 2 issues:
1) I can not figure out a code to save the file as UTF 8
2) and when I manually save it as UTF 8 and when I open that file in excel, it shows the same text in same format and not in converted version. The file opens fine in notepad though.
Thanks in advance:)
 

Excel Facts

VLOOKUP to Left?
Use =VLOOKUP(A2,CHOOSE({1,2},$Z$1:$Z$99,$Y$1:$Y$99),2,False) to lookup Y values to left of Z values.

Joe4

MrExcel MVP, Junior Admin
Joined
Aug 1, 2002
Messages
60,159
Office Version
  1. 365
Platform
  1. Windows
1. See here: How to manually save a CSV file with UTF-8 encoding — Workstars 0.0.1 documentation

2. That is because when Excel open CSV files, it automatically does its own conversions on the data. So what you are seeing may not truly be what actually is contained in the file.
For this reason, you should NEVER use Excel to view a CSV file, if you wish to see what the data actually looks like. You need to use a text editor, like NotePad.
If it looks correct in NotePad, then it is good.
 

Anaya Zeeshan

New Member
Joined
Nov 4, 2021
Messages
13
Office Version
  1. 365
Platform
  1. Windows
1. See here: How to manually save a CSV file with UTF-8 encoding — Workstars 0.0.1 documentation

2. That is because when Excel open CSV files, it automatically does its own conversions on the data. So what you are seeing may not truly be what actually is contained in the file.
For this reason, you should NEVER use Excel to view a CSV file, if you wish to see what the data actually looks like. You need to use a text editor, like NotePad.
If it looks correct in NotePad, then it is good.
Thank you for your reply.
Is there any way to automatically save it as utf - 8 using a vba code?
 

Joe4

MrExcel MVP, Junior Admin
Joined
Aug 1, 2002
Messages
60,159
Office Version
  1. 365
Platform
  1. Windows
Yes, you can use the SaveAs as choose the right file type.
If you turn on your Macro Recorder, and record yourself manually saving the file with the correct file type, you will see what the code needs to look like.
 

Anaya Zeeshan

New Member
Joined
Nov 4, 2021
Messages
13
Office Version
  1. 365
Platform
  1. Windows
Thanks alot. One last question, is there anyway to convert excel data to utf-8 standard without saving it as csv?
 

Forum statistics

Threads
1,148,396
Messages
5,746,452
Members
424,020
Latest member
LongDoo

We've detected that you are using an adblocker.

We have a great community of people providing Excel help here, but the hosting costs are enormous. You can help keep this site running by allowing ads on MrExcel.com.
Allow Ads at MrExcel

Which adblocker are you using?

Disable AdBlock

Follow these easy steps to disable AdBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the icon in the browser’s toolbar.
2)Click on the "Pause on this site" option.
Go back

Disable AdBlock Plus

Follow these easy steps to disable AdBlock Plus

1)Click on the icon in the browser’s toolbar.
2)Click on the toggle to disable it for "mrexcel.com".
Go back

Disable uBlock Origin

Follow these easy steps to disable uBlock Origin

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back

Disable uBlock

Follow these easy steps to disable uBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back
Top