Reputation: 35
i am trying to pass string value to visio shape data table, but i can able to pass number value to visio shape table & when pass string value python is throwing error.
Please help me what missing take i have done.
Thanks in advance for the kind support.
import win32com.client
appVisio = win32com.client.Dispatch("Visio.Application")
appVisio.Visible =1
doc = appVisio.Documents.Add(r'C:\Users\anas\Visio\Input\Template.vsdx')
pagObj = doc.Pages.Item(1)
stnObj = appVisio.Documents("Oneweb.vssx")
mastObj = stnObj.Masters("NDC")
shpObj1 = pagObj.Drop(mastObj, 4.25, 5.5)
shpObj1.Text = "This is some text."
# set the cell
shpObj1.CellsU("Prop.SiteName").FormulaU = "=2.5" // successfully running
shpObj2 = pagObj.Drop(mastObj, 2, 2)
shpObj2.Text = "This is some more text."
shpObj2.CellsU("Prop.SiteName").FormulaU = "Test" // getting error in this line
connectorMaster = appVisio.Application.ConnectorToolDataObject
connector = pagObj.Drop(connectorMaster, 0, 0)
connector.Cells("BeginX").GlueTo(shpObj1.Cells("PinX"))
connector.Cells("EndX").GlueTo(shpObj2.Cells("PinX"))
doc.SaveAs(r'C:\Users\anas\Visio\Output\MyDrawing.vsd')
doc.Close()
appVisio.Visible =0
appVisio.Quit()
Upvotes: 0
Views: 37
Reputation: 35
It works after adding double quotes before and after the string value, like this:
shpObj2.CellsU("Prop.SiteName").FormulaU = chr(34) + "Test" + chr(34)
Note that chr(34)
returns "
.
Upvotes: 0