[Python] Pass string to visio shape data table using python

Discussão em 'Python' iniciado por Stack, Fevereiro 21, 2025.

  1. Stack

    Stack Membro Participativo

    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()

    Continue reading...

Compartilhe esta Página