使用VBA代码可以编辑Visio图形中的Excel OLE链接。以下是示例代码:
Sub editShapeExcelOLE()
Dim shp As Shape Dim i As Integer
'Loop through all shapes on the active page For Each shp In ActivePage.Shapes
If shp.Type = visTypeOLEObject Then
'Check if the OLE object is an Excel spreadsheet
If InStr(shp.OLEFormat.Object.Name, "Excel") > 0 Then
'Edit the link to the Excel spreadsheet
For i = 1 To shp.OLEFormat.Object.LinkSources(visLinkSourcesNoPending).Count
shp.OLEFormat.Object.LinkSources(visLinkSourcesNoPending)(i) = "C:\MyExcelFile.xlsx"
Next i
End If
End If
Next shp
End Sub
以上代码会循环访问当前页面中的所有图形,如果图形是一个Excel OLE对象,则会将其链接到指定的Excel文件。将“C:\MyExcelFile.xlsx”替换为您要链接的Excel文件的路径即可。
上一篇:编辑userChrome.css文件以隐藏标签工具栏和导航栏。
下一篇:编辑VS Code编辑器的wordSeparator设置,当我删除一个完整的单词时,会在第一个大写字母后停止(例如,capLocks ---> cap)。