

We got a request from a client, to convert the accented characters of multiple Excel files to plain Latin. Excel VBA is great and really handy but there is no method to perform such a task using VB code. On the other hand C# inherits all beautiful .Net libraries, and it’s so easy to solve the above problem. Why not bring the .Net world close to the “vintage” world of VBA?
So here is what we did. We prepared a method in C# that fixes the problem and then made it public to the VBA IDE:
string accentedStr = "Staré Město";
byte[] tempBytes;
tempBytes = Encoding.GetEncoding("ISO-8859-8").GetBytes(accentedStr);
string asciiStr = Encoding.UTF8.GetString(tempBytes);
And from the Excel VBA IDE:
We registered the C# Library from Tools | References, and we added the following method:
Public Sub Convert()
Application.Cursor = xlWait
'Create Object from C#
Dim obj As CSharpTools.CSharpTools
Set obj = New CSharpTools.CSharpTools
Dim CountRows As Long
Dim ActiveCol
ActiveCol = ActiveCell.Column
Cells(1, ActiveCol).Select
'Get the last row in the current region
CountRows = Cells(1, ActiveCol).End(xlDown).Row
Dim i As Long
For i = 1 To CountRows
'Convert each cell to Latin characters
Cells(i, ActiveCol).Value = obj.ConvertFromUTF8ToLatin(Cells(i, ActiveCol).Value)
Next i
Application.Cursor = xlDefault
End Sub
With the above code we can convert a whole column at no time at all !
If you need assistance on converting your documents please use our Contacts Form, we would love to help !
Necessary cookies are absolutely essential for the website to function properly. These cookies ensure basic functionalities and security features of the website, anonymously.
Cookie | Duration | Description |
---|---|---|
cookielawinfo-checbox-analytics | 11 months | This cookie is set by GDPR Cookie Consent plugin. The cookie is used to store the user consent for the cookies in the category "Analytics". |
cookielawinfo-checbox-functional | 11 months | The cookie is set by GDPR cookie consent to record the user consent for the cookies in the category "Functional". |
cookielawinfo-checbox-others | 11 months | This cookie is set by GDPR Cookie Consent plugin. The cookie is used to store the user consent for the cookies in the category "Other. |
cookielawinfo-checkbox-necessary | 11 months | This cookie is set by GDPR Cookie Consent plugin. The cookies is used to store the user consent for the cookies in the category "Necessary". |
cookielawinfo-checkbox-performance | 11 months | This cookie is set by GDPR Cookie Consent plugin. The cookie is used to store the user consent for the cookies in the category "Performance". |
viewed_cookie_policy | 11 months | The cookie is set by the GDPR Cookie Consent plugin and is used to store whether or not user has consented to the use of cookies. It does not store any personal data. |
Functional cookies help to perform certain functionalities like sharing the content of the website on social media platforms, collect feedbacks, and other third-party features.
Performance cookies are used to understand and analyze the key performance indexes of the website which helps in delivering a better user experience for the visitors.
Analytical cookies are used to understand how visitors interact with the website. These cookies help provide information on metrics the number of visitors, bounce rate, traffic source, etc.
Advertisement cookies are used to provide visitors with relevant ads and marketing campaigns. These cookies track visitors across websites and collect information to provide customized ads.
Other uncategorized cookies are those that are being analyzed and have not been classified into a category as yet.
GET INSTANT ACCESS TO YOUR FREE 30 DAYS TRIAL
ENTER YOUR EMAIL & DOWNLOAD
GET INSTANT ACCESS TO YOUR FREE GIFT
ENTER YOUR EMAIL & DOWNLOAD
GET INSTANT ACCESS TO YOUR FREE GIFT
ENTER YOUR EMAIL & DOWNLOAD
GET INSTANT ACCESS TO YOUR FREE E-BOOK
ENTER YOUR EMAIL & DOWNLOAD
GET INSTANT ACCESS TO YOUR FREE E-BOOK
ENTER YOUR EMAIL & DOWNLOAD
GET INSTANT ACCESS TO YOUR FREE E-BOOK
ENTER YOUR EMAIL & DOWNLOAD
GET INSTANT ACCESS TO YOUR FREE E-BOOK
ENTER YOUR EMAIL & DOWNLOAD
GET INSTANT ACCESS TO YOUR FREE GIFT
ENTER YOUR EMAIL & DOWNLOAD