I want to read all text in a PowerPoint file using VBA, and write them to external file (or some other way) to use in another Software.
I wrote this code:
Sub ReadFileText()
On Error Resume Next
Dim shp As Shape
For Each sld In ActivePresentation.Slides
For Each shp In sld.Shapes
If shp.TextFrame.HasText Then
MsgBox shp.TextFrame.TextRange.Text
' if text was read successfully, I can save it to a text or json file.
End If
Next shp
Next sld
End Sub
Some shapes includes non-ASCII (UTF-8) characters in text. VBA returns them as "?" character!
How can I read shape text as UTF-8 string?
PowerPoint/VBA can work internally with UTF-8 but as Tim mentions, can't display UTF-8 text in message boxes/debug window.
But when I add some Japanese text to a slide, then do
Activewindow.Selection.ShapeRange(1).TextFrame.TextRange.Copy
I can then paste into a notepad UTF-8 file and get the correct text.
What you get may vary depending on what you DO with the copied text.