Manipulating text with symbols in PowerPoint using VBA

I am trying to use VBA to manipulate text in a PowerPoint.

I have formatted text in a frame with greek symbols, superscript and subscript. I want to divide that text into two frames. For example I use something like this:

Dim frame1Text As String
Dim frame2Text As String
Set frame1 = ActivePresentation.Slides(1).Shapes(1).TextFrame
Set frame2 = ActivePresentation.Slides(1).Shapes(2).TextFrame
frame1Text = frame1.TextRange.Text
frame2Text = Right(frame1Text, Len(frame1Text) - 10)
frame1Text = Left(frame1Text, Len(frame1Text) - Len(frame2Text))
frame1.TextRange.Text = frame1Text
frame2.TextRange.Text = frame2Text

As a result there are symbols and formatting lost. Is there any way to make it better? Thanks for any help.

Answers


If possible, I would duplicate the shape and then delete what you don't want in the text. That way all formatting will be retained, character-by-character. Something along the lines of this:

Option Explicit

Sub CopyText()
  Dim oShp1 As Shape
  Dim oShp2 As Shape

  Set oShp1 = ActivePresentation.Slides(1).Shapes(1)
  oShp1.Copy
  ActiveWindow.View.Slide.Shapes.Paste

  Set oShp2 = ActivePresentation.Slides(1).Shapes(ActivePresentation.Slides(1).Shapes.Count)

  With oShp1.TextFrame.TextRange
    .Text = Left(.Text, 10)
  End With

  With oShp2.TextFrame.TextRange
    .Text = Right(.Text, Len(.Text) - Len(oShp1.TextFrame.TextRange.Text))
  End With
End Sub

Need Your Help

Openssl Mach-O linker error for architecture i386 and armv7

xcode architecture error-handling linker openssl

I am trying to implement openssl code I found into my project but I get these linker errors that aren't going away. I checked that the frameworks are properly linked and even included the library and

EJB Stateless Initialization Pattern

java-ee design-patterns architecture ejb-3.1

I have an EJB Stateless Session Bean. I have these requirements: