[python-win32] Trying to set tab stops in Visio shape

Kevin Miller kevin_miller at capgroup.com
Tue Jan 10 12:31:15 EST 2017


In Visio, I am trying to set a tab stop in a text box that doesn't have any tabs.
I'm running Window 7, Viso 2013, and Python 2.7.10.

-----------------
import win32com.client
from win32com.client import constants

win32com.client.gencache.EnsureDispatch("Visio.Application")
visapp = win32com.client.Dispatch("Visio.Application")
doc = visapp.Documents.Add("")
page = visapp.ActivePage

s1 = page.DrawRectangle(1.0, 8.5, 3.75, 9.75) s1.Text = "this\tis\ta\ttest"
s1.CellsSRC(constants.visSectionTab, 0, constants.visTabStopCount).FormulaU = "1"
s1.CellsSRC(constants.visSectionTab, 0, constants.visTabPos).FormulaU = "0.7 in"
s1.CellsSRC(constants.visSectionTab, 0, constants.visTabAlign).FormulaU = "0"
s1.CellsSRC(constants.visSectionTab, 0, 3).FormulaU = "0"
-----------------

But the tab shows up as UNKNOWN_TOKEN_0
Some posts say that I need to set the RowType first.
s1.RowType(constants.visSectionTab, constants.visRowTab) = 151
where 151 is visTagTab10, but this gets an error: SyntaxError: can't assign to function call

I hope you can help.

____________________________________________
Kevin Miller
(949) 705-2926  /  x52926

-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://mail.python.org/pipermail/python-win32/attachments/20170110/e2fb7d11/attachment.html>


More information about the python-win32 mailing list