VB: TheText = (superscript) "2"

N

Nikolay Klinachyov

Please correct my VB-code:
Shapes.ItemFromID(3).Text = "Ts<sup>2</sup>+1"

(HTML analogue: <p>Ts<sup>2</sup>+1</p>)

Unfortunately this code is not desirable:
Shapes.ItemFromID(3).Text = "Ts^2+1"
 
M

Markus Breugst

Hello Nikolay,

so you want to have different text formats within a single shape. The only
way I know is to create multiple "Character" tables in the ShapeSheet.

Here's a VB example. It sets the text of shape "Sheet.1" to "xy2+1" where
"xy" is normal, and "2+1" is superscript.

Best regards,
Markus

Public Sub SetText()
Dim myShape As Shape
Dim myChar As Characters

Set myShape = ThisDocument.Pages(1).Shapes("Sheet.1")
myShape.Text = "xy2+1"
Set myChar = myShape.Characters

myChar.Begin = 0
myChar.End = 1
myChar.CharProps(VisCellIndices.visCharacterPos) = 0
myChar.Begin = 2
myChar.End = 5
myChar.CharProps(VisCellIndices.visCharacterPos) = 1
End Sub
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top