I’m coding in Python in order to update a Word Document (loaded as DOCX) to contain VBA code.
This VBA code will change a ContentControl everytime a Dropdown menu selection changes and so far programming this on Aspose.words is working.
What isn’t working is that when saving this file as DOCM, all accents previously written in VBA are lost, and the letters are overwritten by their closest non-accent counterpart, for instance, ‘ã’ becomes ‘a’, ‘ç’ becomes ‘c’ and so on.
I’ve tried using aw.loading.EditingLanguage.PORTUGUESE_BRAZIL for both add_editing_language and default_editing_language when opening a new file, but that didn’t change anything. In fact, doc.styles.default_font.locale_id returns a different ID than PORTUGUESE_BRAZIL.
I’ve also tried looking for encoding options on OoxmlSaveOptions, but they don’t seem to be available.
Here’s a snippet of the VBA code I’m getting right after saving:
ElseIf ContentControl.Tag = "Margem_Esquerda_Master" Then
Set oNode = ContentControl.XMLMapping.CustomXMLPart.SelectSingleNode(Replace(ContentControl.XMLMapping.XPath, "Margem_Esquerda_Master", "Margem_Esquerda_Slave"))
Select Case Content
Case "Teste1"
oNode.Text = "Caracteres sao perdidos."
Case "Teste2"
oNode.Text = "Autoafirmacao"
Case Else
oNode.Text = "Opcao ainda nao escolhida."
End Select
Needless to say, the original VBA code did have the accents in place.
How to keep Brazilian Portuguese accents when saving VBA code in DOCM?
Thank you in advance for your support.