Skip to content

Instantly share code, notes, and snippets.

@dajare
Last active April 19, 2017 15:03
Show Gist options
  • Save dajare/c452fd291d5d89173ac36a4b89f25245 to your computer and use it in GitHub Desktop.
Save dajare/c452fd291d5d89173ac36a4b89f25245 to your computer and use it in GitHub Desktop.
LibreOffice Writer Basic macro to insert string "Th" without ligature
Sub insert_Th_no_ligature
Dim oDoc as variant
oDoc = ThisComponent
Dim oCurrentController as variant
oCurrentController = oDoc.getCurrentController()
Dim oTextViewCursor as variant
oTextViewCursor = oCurrentController.getViewCursor()
Dim oText as variant
If IsEmpty(oTextViewCursor.Cell) Then
oText=oTextViewCursor.Text
Else
oText=oTextViewCursor.Cell.Text
End If
oText.insertString(oTextViewCursor,"T" & chr(clng("&H2060")) & "h",false)
End Sub
@dajare
Copy link
Author

dajare commented Apr 19, 2017

Uses U+2060 = Unicode word joiner:

However, if encountered elsewhere it should, according to Unicode, be treated as a "zero-width non-breaking space."


Macro adapted from Ask.LibO Q&A. For macro string concatenation, see Macro Guide, p. 67 (70 of PDF).

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment