How to Save Excel Files with Macros and UTF-8 Text
Question details
The user needs to save an Excel file containing both VBA macros and UTF-8 encoded text (like Hebrew) without losing either the script or the character encoding.

- Product
- Microsoft Excel
- Device & OS
- not provided
- Scenario
- Trying to save an Excel workbook that contains both automated VBA code and foreign language text that requires UTF-8 encoding.
- Observed behavior
- Saving the file as a CSV drops all VBA macros because it is plain text, and saving it as an XLSX drops macros due to security format restrictions, making it difficult to preserve both simultaneously in a single standard format.
Ensure that your VBA macros are fully written and compiled, and verify that any foreign language text displays correctly in your active worksheet before saving.
Save as XLSM and Export a Separate UTF-8 CSV
To maintain both your VBA macros and UTF-8 text, you must use a dual-file approach: keep a master macro-enabled workbook and export plain-text data as needed.
A single file format cannot satisfy both needs if you intend to use CSV. CSV is strictly a plain-text format and cannot store VBA code. Conversely, standard Excel macro formats are binary or XML-based. The best practice is to separate your database/macro storage from your text data export.
Go to 'File' > 'Save As'. In the file format dropdown, choose 'Excel Macro-Enabled Workbook (*.xlsm)' or 'Excel Binary Workbook (*.xlsb)'. This safely stores your VBA code alongside your data.
When you need to share or upload the text data (such as Hebrew), navigate to 'File' > 'Save As' or 'Export'. Select 'CSV UTF-8 (Comma delimited) (*.csv)' as the format.
Excel will prompt a warning that saving as CSV does not support multiple sheets or macros. Accept this to generate the text export, then close the CSV and continue working primarily in your XLSM file.

Easily Manage Macros and UTF-8 Data with WPS Office
WPS Spreadsheet provides robust support for saving macro-enabled workbooks (XLSM) and exporting UTF-8 CSV files, ensuring your VBA scripts and international text are perfectly preserved without compatibility issues.
- 1. Open WPS Spreadsheet: Launch WPS Office and open your workbook containing macros and UTF-8 text.
- 2. Save as XLSM: Click the 'Menu' button, select 'Save As', and choose 'Microsoft Excel Macro-Enabled Workbook (*.xlsm)' to secure your VBA code.
- 3. Export UTF-8 CSV: To export your text data, go back to 'Menu' > 'Save As', select 'CSV (Comma delimited) (*.csv)', and ensure your encoding is set to UTF-8 in the prompt.

Frequently Asked Questions
Why does my CSV file lose macros when saved in Excel?
CSV stands for Comma Separated Values. It is a plain-text format designed solely for tabular data separation. It physically lacks the structural capacity to store VBA code, formatting, or formulas.
Can standard XLSX files store VBA macros?
No. The standard XLSX format was designed by Microsoft to be macro-free for security reasons, preventing malicious code from running silently. To save macros, you must intentionally use the XLSM (Macro-Enabled) or XLSB (Binary) formats.
How do I ensure Hebrew or non-Latin text doesn't turn into question marks in a CSV?
When saving as a CSV, you must select the 'CSV UTF-8 (Comma delimited)' option in the Save As dialog instead of the standard CSV option. This guarantees special characters are encoded correctly and not lost.




