-1

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()
1
  • need to add double before the string value then only visio data will accept it shpObj2.CellsU("Prop.SiteName").FormulaU = chr(34) + "Test" + chr(34) Commented Feb 21 at 14:18

1 Answer 1

0

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 ".

Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.