Hi guys,

Trying to combine some normally written text and an equation (using the inbuilt insert equation feature inside powerpoint). Quite easily done doing it manually by hand, but with VBA proving tricky for me.

I've managed to do it in separate textboxes but when I try and do it together in one textbox, it formats all the text inside the textbox as an equation.

E.g. 'Solve 4x+2=8' I would want the 'solve' to be written as a normal string/text, however, the 4x+2=8 I would like to be written using the powerpoint insert equation feature.


The code to write out an equation using the powerpoint inbuilt tool is this. I tried to add the word 'solve' as a string and concatenate with the equation part, but the 'solve' is still appearing like an equation.

Sub insert_equation()

Dim a As Integer
a = 2


Dim word As String


word = "Solve "


Application.CommandBars.ExecuteMso ("InsertBuildingBlocksEquationsGallery")


With ActiveWindow.Selection.ShapeRange.TextFrame
With .TextRange
.Font.Size = 22
.Text = word & "2x^2+7x+6=0"
'.Text = a & "x"
End With
End With


Application.CommandBars.ExecuteMso ("EquationProfessional")


End Sub


First textbook is just normal string, second is with the code above, third is how I would like it to appear.

eqn.jpg

Thanks alot,

S