• Skip to main content
  • Skip to header right navigation
  • Skip to site footer

My Online Training Hub

Learn Dashboards, Excel, Power BI, Power Query, Power Pivot

  • Courses
  • Pricing
    • Free Courses
    • Power BI Course
    • Excel Power Query Course
    • Power Pivot and DAX Course
    • Excel Dashboard Course
    • Excel PivotTable Course – Quick Start
    • Advanced Excel Formulas Course
    • Excel Expert Advanced Excel Training
    • Excel Tables Course
    • Excel, Word, Outlook
    • Financial Modelling Course
    • Excel PivotTable Course
    • Excel for Customer Service Professionals
    • Excel for Operations Management Course
    • Excel for Decision Making Under Uncertainty Course
    • Excel for Finance Course
    • Excel Analysis ToolPak Course
    • Multi-User Pricing
  • Resources
    • Free Downloads
    • Excel Functions Explained
    • Excel Formulas
    • Excel Add-ins
    • IF Function
      • Excel IF Statement Explained
      • Excel IF AND OR Functions
      • IF Formula Builder
    • Time & Dates in Excel
      • Excel Date & Time
      • Calculating Time in Excel
      • Excel Time Calculation Tricks
      • Excel Date and Time Formatting
    • Excel Keyboard Shortcuts
    • Excel Custom Number Format Guide
    • Pivot Tables Guide
    • VLOOKUP Guide
    • ALT Codes
    • Excel VBA & Macros
    • Excel User Forms
    • VBA String Functions
  • Members
    • Login
    • Password Reset
  • Blog
  • Excel Webinars
  • Excel Forum
    • Register as Forum Member

Special Accented Characters|VBA & Macros|Excel Forum|My Online Training Hub

You are here: Home / Special Accented Characters|VBA & Macros|Excel Forum|My Online Training Hub
Avatar
sp_LogInOut Log In sp_Registration Register
sp_Search Search
Advanced Search|Last Search Results
Search
Forum Scope




Match



Forum Options



Minimum search word length is 3 characters - maximum search word length is 84 characters
sp_Search Search
sp_RankInfo
Lost password?
sp_CrumbsHome HomeExcel ForumVBA & MacrosSpecial Accented Characters
sp_PrintTopic sp_TopicIcon
Special Accented Characters
Avatar
Kevin Junk
Member
Members
Level 0
Forum Posts: 23
Member Since:
October 18, 2018
sp_UserOfflineSmall Offline
1
September 27, 2019 - 9:50 am
sp_Permalink sp_Print

This is something that comes up every now and then and I haven't been able to find a solution.

My workflow is 1. copying and pasting text from web pages to Excel;  and 2. exporting that data to text files using VBA.

To illustrate this I have simplified the process using the attached xlsm & txt files.

Here is the issue: in cell A1 is the name of the composer Dvořák - this was copied from a web page and the accented characters preserved by Excel - so far so good. When I export that text to a text file using the VBA in the xlsm file the special accent over the 'r' is lost. How can I modify my VBA to preserve that special character (and others)?

I have a feeling my VBA is too simple and that it has something to do with Unicode but that's a bit of a black hole for me.

Avatar
Catalin Bombea
Iasi, Romania
Admin
Level 10
Forum Posts: 1807
Member Since:
November 8, 2013
sp_UserOfflineSmall Offline
2
September 29, 2019 - 2:04 pm
sp_Permalink sp_Print

Hi Kevin,

I tested your code, and the content of that cell was accurately saved in the text file, I was not able to replicate your issue.

Try FileSystemObject to create the text file, might be more reliable.

Sub specialchar()
Dim wbk As Workbook
Dim OutputTxt As String
Dim OutPutFile As Object
Dim StrPath As String

Set wbk = ThisWorkbook
StrPath = "E:\TestOutput.txt"

Dim fso As Object
Set fso = CreateObject("Scripting.FileSystemObject")

Set OutPutFile = fso.CreateTextFile(StrPath)
OutPutFile.WriteLine wbk.Worksheets(1).Cells(1).Value
OutPutFile.Close
Set fso = Nothing
Set OutPutFile = Nothing

End Sub

Avatar
Kevin Junk
Member
Members
Level 0
Forum Posts: 23
Member Since:
October 18, 2018
sp_UserOfflineSmall Offline
3
September 30, 2019 - 8:06 am
sp_Permalink sp_Print

Hi Catalin

I guess that not being able to replicate the issue will be impossible to troubleshoot.

I'll just have to put up with a less than ideal process. That seems to be the case so often these days - software promises a lot but more often than not it fails to deliver exactly what is needed.

Avatar
Philip Treacy
Admin
Level 10
Forum Posts: 1509
Member Since:
October 5, 2010
sp_UserOfflineSmall Offline
4
September 30, 2019 - 12:18 pm
sp_Permalink sp_Print

Hi Kevin,

If you use Catalin's code but modify this line to open the text file as UniCode rather than ASCII you might find it keeps your accented characters.  Works for me anyway.

Set OutPutFile = fso.CreateTextFile(StrPath, True, True)

https://docs.microsoft.com/en-.....ile-method

Cheers

Phil

sp_Feed
Go to top
Forum Timezone: Australia/Brisbane
Most Users Ever Online: 245
Currently Online: Amin Khajeh
Guest(s) 10
Currently Browsing this Page:
1 Guest(s)
Top Posters:
SunnyKow: 1432
Anders Sehlstedt: 870
Purfleet: 412
Frans Visser: 346
David_Ng: 306
lea cohen: 219
A.Maurizio: 202
Jessica Stewart: 202
Aye Mu: 201
jaryszek: 183
Newest Members:
Lawrence Miu
Jo Saies
Paul Pritchard
Monique Roussouw
Keith Aul
Richard Dunks
Manjula Mangalmurti
Thomas Quidort
Jamie Preece
Bob Smith
Forum Stats:
Groups: 3
Forums: 24
Topics: 6192
Posts: 27146

 

Member Stats:
Guest Posters: 49
Members: 31848
Moderators: 3
Admins: 4
Administrators: Mynda Treacy, Philip Treacy, Catalin Bombea, FT
Moderators: MOTH Support, Velouria, Riny van Eekelen
© Simple:Press —sp_Information

Sidebar

Blog Categories

  • Excel
  • Excel Charts
  • Excel Dashboard
  • Excel Formulas
  • Excel PivotTables
  • Excel Shortcuts
  • Excel VBA
  • General Tips
  • Online Training
  • Outlook
  • Power Apps
  • Power Automate
  • Power BI
  • Power Pivot
  • Power Query
microsoft mvp logo
trustpilot excellent rating
Secured by Sucuri Badge
MyOnlineTrainingHub on YouTube Mynda Treacy on Linked In Mynda Treacy on Instagram Mynda Treacy on Twitter Mynda Treacy on Pinterest MyOnlineTrainingHub on Facebook
 

Company

  • About My Online Training Hub
  • Disclosure Statement
  • Frequently Asked Questions
  • Guarantee
  • Privacy Policy
  • Terms & Conditions
  • Testimonials
  • Become an Affiliate

Support

  • Contact
  • Forum
  • Helpdesk - For Technical Issues

Copyright © 2023 · My Online Training Hub · All Rights Reserved. Microsoft and the Microsoft Office logo are trademarks or registered trademarks of Microsoft Corporation in the United States and/or other countries. Product names, logos, brands, and other trademarks featured or referred to within this website are the property of their respective trademark holders.