LO Calc is entering a Unicode apostrophe in manual text entries, rather than an ASCII apostrophe which I need for exporting in a GPX file going to Garmin Basecamp. I can change this using the menu item Tools>Autocorrect options, but this is not reliable for someone else using the spreadsheet. Using a macro, I need to scan for the Unicode character U+2019, and replace it with the ASCII apostrophe. What is a good approach for this?
Code:
Sub doIt()
doc0 = ThisComponent
rd = doc0.Sheets(0).createReplaceDescriptor()
rd.SearchRegularExpression = True
rd.SearchString = "\u2019"
rd.ReplaceString = "'"
For Each sheet In doc0.Sheets
sheet.ReplaceAll(rd)
Next sheet
End Sub
There seems no longer to be a difference between createSerachDescriptor
and createReplaceDescriptor
.
You can also do it via the dispatch helper (slot machine). The code you can record to do it that way is much longer, however.
(Originally by @homefire Concerted from an answer to a comment.)
Simple Regular Expression. Thank you.