Thursday, September 12, 2013

Powerpoint VBA/Python: Applying different Font size to words in TextBox Programatically

Powerpoint VBA/Python: Applying different Font size to words in TextBox
Programatically

Aim: To programatically adjust Font size of group of words in a SINGLE
textbox in powerpoint.
Details:
I have two lists:
Labels = ["Mahon Point Retail","Park","Blackpool Drive","Balance","Finglas
Point"]
FontSize = [10,23,15,20,40]
I would like to apply the font sizes in FontSize to the labels in Labels,
by their indexes.
My script thus far:
#add all items in Labels to a single textbox
for i, label in enumerate(labels):
Shape.TextFrame.TextRange.Text += " " + label
#apply font size from FontSize list to its corresponding label
for x, num in enumerate(FontSize, 1):
Shape.TextFrame.TextRange.Words(x).Font.Size = int(num)
The PROBLEM:
I believe the problem lies with the use of "Words(x)" property, is there
any way I can define what a word is? because right now it thinks "Mahon
Point Retail" is 3 words (which it is) but I would like it to see it as a
single word...
Any advice?

No comments:

Post a Comment