对于一个项目,我正在创建一个用户窗体,它从文本框中读取值并使用数据生成形状。 因此,在删除形状后,我想更改形状数据行,例如“Prop.SO_Name”。
当我使用时
shp.CellsU("Prop.SO_Name").FormulaU = """Test"""
它工作得很好。但我想从文本框中读取一个值。我试过了
Dim cell As Visio.cell
Set cell = shp.Cells("Prop.SO_Name")
cell.FormulaU = TextBox2.Value
但它返回一个运行时错误。我也尝试过
Dim str as String
str = Textbox2.value
Dim cell As Visio.cell
Set cell = shp.Cells("Prop.SO_Name")
cell.FormulaU = str
结果相同。
我查看了 documentation对于 FormulaU 属性(property),但他们显然做到了,就像我尝试过的那样。显然我错过了一些东西。
最佳答案
`尝试使用
Dim cell As Visio.cell
Set cell = shp.Cells("Prop.SO_Name")
cell.FormulaU = chr(34) & UserForm1.TextBox2.Value & chr(34)
更新您尝试将字符串写入 ShapeSheet 单元格!字符串中的双引号是告诉 VB[A] 创建一个嵌入引号字符的字符串的一种方法。
关于vba - Visio 使用 VBA 更改形状数据/属性,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/51192476/