jb30
jb30

Reputation: 11

Powerpoint 2013 vba create Equation / Mathzone

I am trying to write a macro that inserts an equation into a PowerPoint slide but I cannot find any command to achieve this.

The only math/equation relating element I found so far is MathZones in the Textrange2 class but I don't think you can create a new equation with that. At least I didn't figure out how.

I don't want to insert an Equation.3 object like it is explained in Create new Equation Macro in PowerPoint 2007 .

The equation should be inserted in the same way as by hitting the Equation button.

I'm searching for hours now without getting even any idea...

Upvotes: 0

Views: 1860

Answers (2)

jb30
jb30

Reputation: 11

Thank you for your help but I finally found the solution I was looking for. It is way easier than I expected...

Application.CommandBars.ExecuteMso ("InsertBuildingBlocksEquationsGallery")

Full Example:

Sub insert_equation()

  Application.CommandBars.ExecuteMso ("InsertBuildingBlocksEquationsGallery")

  With ActiveWindow.Selection.ShapeRange.TextFrame
  With .TextRange
      .Font.Size = 16
      .Text = "\omega"
  End With
  End With

  Application.CommandBars.ExecuteMso ("EquationProfessional")

End Sub

Upvotes: 1

Steve Rindsberg
Steve Rindsberg

Reputation: 14809

This might help get you started:

Insert an equation into an existing text box then while it's selected:

Sub WhatIsTheEquationMadeOf()

Dim x as Long

With ActiveWindow.Selection.ShapeRange(1).TextFrame2.TextRange
   For x = 1 to Len(.MathZones(1).Text)
      Debug.Print AscW(Mid$(.MathZones(1).Text,x,1))
   Next
End With

End Sub

That will give you some idea what it's expecting. Then you may (?) be able to set .Mathzones(1).Text to the same values in another text box as a test to see if the equation appears.

Upvotes: 0

Related Questions