【Visio】利用visio2010宏画中文流程图


前言

python虽然能够绘制visio流程图,但是需要进行安装,本文参考mscn提供了一个visio自带的vb脚本创建流程图的方法。


一、参考网址

参考链接: https://docs.microsoft.com/en-us/previous-versions/office/developer/office-2010/gg650651(v=office.14)

二、使用步骤

1.创建宏

按下Alt+F8 或在菜单栏选择“视图->宏”
创建宏示意图
添入VB代码

Sub DrawProcess()
    Dim vsoDocumentStencil As Document
    Dim vsoStencilDocument As Document
    Dim vsoPage As Page
    Dim vsoMasterProcess As Master
    Dim vsoMasterDecision As Master
    Dim vsoMasterSubProcess As Master
    Dim vsoMasterContainer As Master
    Dim vsoShapeProcess1 As Shape
    Dim vsoShapeProcess2 As Shape
    Dim vsoShapeProcess3 As Shape
    Dim vsoShapeProcess4 As Shape
    Dim vsoShapeToSubProcessA As Shape
    Dim vsoShapeToSubProcessB As Shape
    Dim vsoShapeDecision1 As Shape
    Dim vsoShapeDecision2 As Shape
    Dim vsoShapeSelection1 As Shape
    Dim vsoShapeSelection2 As Shape
    Dim vsoShapeContainer As Shape
    Dim vsoSelection As Selection
   
    Dim intDiagramServices As Integer
    intDiagramServices = ActiveDocument.DiagramServicesEnabled
    intDiagramServices = visServiceVersion140
    
    ' Specify masters to drop.
    Set vsoMasterProcess = Visio.Documents("BASFLO_M.VSS").Masters.ItemU("Process")
    Set vsoMasterDecision = Visio.Documents("BASFLO_M.VSS").Masters.ItemU("Decision")
    Set vsoMasterSubProcess = Visio.Documents("BASFLO_M.VSS").Masters.ItemU("Subprocess")
    
    ' Set the Page object equal to the first page.
    Set vsoPage = ThisDocument.Pages(1)
    
    ' Create the first process shape.
    Set vsoShapeProcess1 = vsoPage.Drop(vsoMasterProcess, 3, 4.5)
    vsoShapeProcess1.Text = "流程 1"
        
    ' Create and connect the first decision shape.
    Set vsoShapeDecision1 = vsoPage.DropConnected(vsoMasterDecision, vsoShapeProcess1, visAutoConnectDirRight)
    vsoShapeDecision1.Text = "判断"
    
    ' Create and connect the second process shape.
    Set vsoShapeProcess2 = vsoPage.DropConnected(vsoMasterProcess, vsoShapeDecision1, visAutoConnectDirRight)
    vsoShapeProcess2.Text = "流程 2"
    
    ' Create and connect one shape to link to a subprocess.
    Set vsoShapeToSubProcessA = vsoPage.DropConnected(vsoMasterProcess, vsoShapeDecision1, visAutoConnectDirDown)
    vsoShapeToSubProcessA.Text = "子流程A"
    
    ' Create and connect another shape to link to a subprocess.
    Set vsoShapeToSubProcessB = vsoPage.DropConnected(vsoMasterProcess, vsoShapeToSubProcessA, visAutoConnectDirDown)
    vsoShapeToSubProcessB.Text = "子流程B"
    
     ' Create and connect the second decision shape.
    Set vsoShapeDecision2 = vsoPage.DropConnected(vsoMasterDecision, vsoShapeProcess2, visAutoConnectDirRight)
    vsoShapeDecision2.Text = "判断"
    
    ' Create and connect the third process shape.
    Set vsoShapeProcess3 = vsoPage.DropConnected(vsoMasterProcess, vsoShapeDecision2, visAutoConnectDirRight)
    vsoShapeProcess3.Text = "流程 3"
    
    ' Create and connect the fourth process shape.
    Set vsoShapeProcess4 = vsoPage.DropConnected(vsoMasterProcess, vsoShapeDecision2, visAutoConnectDirDown)
    vsoShapeProcess4.Text = "流程 4"
    
    Set vsoShapeSelection1 = vsoPage.Shapes.Item(6)
    Set vsoShapeSelection2 = vsoPage.Shapes("流程.8")
    
    ActiveWindow.DeselectAll
    Set vsoSelection = ActiveWindow.Selection
    
    ' Select two shapes to add to a container.
    vsoSelection.Select vsoShapeSelection1, visSelect
    vsoSelection.Select vsoShapeSelection2, visSelect
      
    ' Draw a container around the shapes.
    Set vsoStencilDocument = Application.Documents.OpenEx(Application.GetBuiltInStencilFile(visBuiltInStencilContainers, visMSMetric), visOpenHidden)
    Set vsoShapeContainer = Application.ActivePage.DropContainer(vsoStencilDocument.Masters.ItemU("Container 5"), vsoSelection)
    vsoShapeContainer.Text = "子流程 模块"
    vsoStencilDocument.Close

End Sub

2.运行宏

Alt+F8打开宏对话框,单击运行
运行宏

3.运行结果

运行结果
在这里插入图片描述


总结

这样非常方便,后续考虑搞一个通过读剪切板实现快速流程图的vb宏程序,方便后续批量快速绘制流程图,减少ctrl+c/v的次数。

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值