亚洲在线久爱草,狠狠天天香蕉网,天天搞日日干久草,伊人亚洲日本欧美

為了賬號安全,請及時綁定郵箱和手機立即綁定
已解決430363個問題,去搜搜看,總會有你想問的

如何使用 Python 讀取和寫入 Visio 形狀數據

如何使用 Python 讀取和寫入 Visio 形狀數據

MMTTMM 2021-09-14 15:04:09
檢查 Visio 形狀中的單元格時,以下代碼不會返回預期值:costVal= shpObj1.CellsU("Prop.Cost") print (costVal)[注意 - 這是一個在我回答時被刪除的問題的摘要,但這是一個有用的問題,所以我想我會問并回答它。]
查看完整描述

1 回答

?
眼眸繁星

TA貢獻1873條經驗 獲得超9個贊

要在 Visio 中獲取 ShapeSheet 單元格的值,您必須對單元格的結果屬性之一進行交互。


import os

import win32com.client


from win32com.client import constants


# this sample assumes that Visio is running, that the ActiveWindow

# is a Drawing window and that the Selection.PrimaryItem

# is a 'Decision' shape from the 'Basic Flowchart Shapes' stencil


# get the running app

appVisio = win32com.client.GetActiveObject("Visio.Application")


# selection gets you the 1 or more selected shapes and

# the PrimaryItem returns the main / primary item in that selection

# or null if the selection is empty

targetShp = appVisio.ActiveWindow.Selection.PrimaryItem


# set the cell

targetShp.CellsU("Prop.Cost").FormulaU = "=2.50"


# read the cell using its 'internal units' result property

print(targetShp.CellsU("Prop.Cost").ResultIU)


查看完整回答
反對 回復 2021-09-14
  • 1 回答
  • 0 關注
  • 736 瀏覽
慕課專欄
更多

添加回答

舉報

0/150
提交
取消
微信客服

購課補貼
聯系客服咨詢優惠詳情

幫助反饋 APP下載

慕課網APP
您的移動學習伙伴

公眾號

掃描二維碼
關注慕課網微信公眾號