???? ID: 305199 - ????? ???????: 04 ?????? 2010 - ??????: 2.0

Visual Basic .NET ?? ??? Visio ?? ???????? ???? ?? ??? ???? ????

?????? ??????This article applies to a different operating system than the one you are using. Article content that may not be relevant to you is disabled.
??? ?? ??????? ???? | ??? ?? ??????? ????

??????

?? ???? ????????? ???? ?? ?? Visual Basic .NET ?? ????? ???? ??? Visio ?? ???????? ???? ?? ??? ???? ?????

???? ???????

????? ??????? ??? ?? ?? ???? ??? ????? ??:
  • Visio ???? ????? ?? ???? ???? ??? ????? ???? ?? ?????? ?? ?? ?? ?????? ????????? ?????? ???? ???
  • ????? ????
  • ???????? ?? ?????? ???
???? two-dimensional ??: ???? ???? ??? ????? ?? ??? ??, ?? ????? ???? ?? ????? ?? ??? ??? ????

Visual Basic .NET ????? ????????? ????? ?? ??? ???

  1. Microsoft Visual Studio .NET ???? ????.. ????? ???????????? ??,????? ????-????? ????, ?? ???? ????????????. ?? ???????????????? ??????????? ????,Visual Basic ?????????, ???? ??? ????? ????Windows ??????????? ???????????????. Form1 ???????? ??? ?? ???? ??..
  2. Visio ???????? ????????? ?? ??? ??? ?????? ??????? ??? ???? ?? ???, ????? ????? ?? ???? ????::
    1. ????? ????????????????? ??,?????? ??????.
    2. ????? ????COM??? ???, ????? ???????? ??? ?? ?? ?? ????? ????, ?? ????? ??????? ????:
      • Visio 2007 ???, ?? ??? ????? ????Microsoft Visio 12.0 ?????? ?????????.
      • Visio 2003 ?? ??? ????? ????Microsoft Visio 11.0 ?????? ?????????.
      • Visio 2002, ?? ??? ????? ????Microsoft Visio 2002 ?????? ?????????.
      ???:??? ???? ??? ??? ?? ????, ?? Microsoft ??????? ???? ?? ?? ??????? ???? ?? Microsoft Office XP ???????? Interop Assemblies (PIAs) ?? ??????? ?????

      Office XP PIA ?? ???? ??? ???? ??????? ?? ???, ????? ???? ?????? ?? ????? ?? ???? ?? Microsoft ???????? ??? ?????::
      328912  (http://support.microsoft.com/kb/328912/ ) Microsoft Office XP ???????? ?????? assemblies (PIAs) ??????? ???? ?? ??? ?????? ???
    3. ????? ????,OK??????????? ??????????? ????? ???? ??? ?? ??????? ???? ?? ??? ??? ??? ???? ?? ????????? ?? ?? ???? ?????? ????? ???? ?? ??? wrappers ????? ???? ?? ??? ????? ????, ?? ????? ???????.
  3. ????? ????????????? ??,????? ?????. Form1 ?? ?? ??? ???????
  4. ???-????? ????Button1. Button1 ?? ??? ????? ???? ????? ?? ??? ????? ????? ???
  5. ??? ????? ???, ????? ??? ?? ???????????? ????
    Private Sub Button1_Click(ByVal sender As System.Object, _
       ByVal e As System.EventArgs) Handles Button1.Click
    End Sub
    					
    with::
    Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As
          System.EventArgs) Handles Button1.Click
       fBuildArray()
       fBuildFlowchart()
    End Sub
    					
  6. ????? ????????????????? ??,??????? ?????.
  7. Module1 ?? ??????? ?? ????? ?? ???????????? ????:
    Module Module1
       Public aryValues(5, 2) As String
       Sub fBuildArray()
          aryValues(0, 0) = "Terminator"
          aryValues(1, 0) = "Document"
          aryValues(2, 0) = "Decision"
          aryValues(3, 0) = "Process"
          aryValues(4, 0) = "Terminator"
    
          aryValues(0, 1) = "Begin Routing Process"
          aryValues(1, 1) = "Gather Customer Data"
          aryValues(2, 1) = "Supported Issue?"
          aryValues(3, 1) = "Dispatch to Queue"
          aryValues(4, 1) = "End Routing Process"
       End Sub
    
       Sub fBuildFlowchart()
          Dim vApp As Visio.Application
          Dim vDoc As Visio.Document
          Dim vFromShape As Visio.Shape
          Dim vToShape As Visio.Shape
          Dim vConnector As Visio.Shape
          Dim vFlowChartMaster As Visio.Master
          Dim vConnectorMaster As Visio.Master
          Dim vStencil As Visio.Document
          Dim dblXLocation As Double
          Dim dblYLocation As Double
          Dim vBeginCell As Visio.Cell
          Dim vEndCell As Visio.Cell
          Dim iCount As Integer
          Const TEMPLATEPATH = "C:\Program Files\Microsoft Office\Visio10\1033\" _
             & "Solutions\Flowchart\Basic Flowchart Shapes (US units).vss"
    
          ' Change this constant to match your choice of location and file name.
          Const SAVENEWFILE = "C:\Simpleflowchart.vsd"
    
          ' Start point measured from the bottom left corner.
          dblXLocation = 4.25
          dblYLocation = 8.5
    
          vApp = New Visio.Application()
          'Create a new document; note the empty string.
          vDoc = vApp.Documents.Add("")
          vStencil = vApp.Documents.OpenEx(TEMPLATEPATH, 4)
    
          For iCount = LBound(aryValues) To UBound(aryValues) - 1
             vFlowChartMaster = vStencil.Masters(aryValues(iCount, 0))
             vToShape = vApp.ActivePage.Drop(vFlowChartMaster, _
                dblXLocation, dblYLocation)
             vToShape.Text = aryValues(iCount, 1)
             If Not vFromShape Is Nothing Then
                If vConnectorMaster Is Nothing Then
                   vConnectorMaster = vStencil.Masters("Dynamic Connector")
                End If
                vConnector = vApp.ActivePage.Drop(vConnectorMaster, 0, 0)
                vBeginCell = vConnector.Cells("BeginX")
                vBeginCell.GlueTo(vFromShape.Cells("AlignBottom"))
                vEndCell = vConnector.Cells("EndX")
                vEndCell.GlueTo(vToShape.Cells("AlignTop"))
                vConnector.SendToBack()
             End If
             vFromShape = vToShape
             vToShape = Nothing
             dblYLocation = dblYLocation - 1.5
          Next
          vDoc.Pages(1).Name = "Flowchart Example"
          Try
             ' Delete the previous version of the file.
             Kill(SAVENEWFILE)
          Catch
          End Try
          vDoc.SaveAs(SAVENEWFILE)
          vDoc.Close()
          vApp.Quit()
          vDoc = Nothing
          vApp = Nothing
          GC.Collect()
       End Sub
    End Module
    					
    ???:??????? ????TEMPLATEPATH???? Visio ??????? ??????? ?? ????? ???? ?? ??? ???????? ??? ???????? ??? ??, ????? ?? ????? ??? ?? ??:
    • Office Visio 2007 ?? ??? ??????? ????? ?? C:\Program Files\Microsoft Office\Visio12\1033\BASFLO_U.VSS.
    • Visio 2003 ?? ??? C:\Program Files\Microsoft Office\Visio11\1033\BASFLO_U.VSS ?? ?? ???? ?? ??? ??????? ?????
    • Visio 2002, ?? ??? ?? ????? ?? ??? ??????? ????? ?? C:\Program Files\Microsoft Visio\Visio10\1033\Solutions\Flowchart\Basic ????????? ???????? (US ???????) .vss.
  8. ????? ???????? ???????? ??,???????.
  9. ?????? ????? ?? ??? Visio ??? C:\Simpleflowchart.vsd ?? ??????

??????

???? ??????? ?? ???, ????? Microsoft ?????? ????? ??????? (MSDN) ??? ????:
Visual Studio ?? ??? Microsoft Office ??????????
http://msdn2.microsoft.com/en-us/library/aa188489(office.10).aspx (http://msdn2.microsoft.com/en-us/library/aa188489(office.10).aspx)

???? ???? ???? ??:
  • Microsoft Office Visio Professional 2007
  • Microsoft Office Visio Professional 2003
  • Microsoft Visio 2002 Professional Edition
  • Microsoft Visual Basic .NET 2002 Standard Edition
??????: 
kbexpertiseinter kbautomation kbhowto kbmt KB305199 KbMthi
???? ?????? ???????????? ?????? ????????
??????????: ?? ???? ?? ???? ??????? ?? ????? ?? Microsoft ????-?????? ?????????? ?????? ?????? ???? ??? ??. Microsoft ???? ??? ????-???????? ?? ????-???????? ????? ?????? ?? ???? ???????? ???? ?? ???? ????? ????? ??? ?? ??? ?????? ?? ???? ???? ???? ??? ????? ??. ???????, ????-???????? ???? ????? ???? ???? ???? ???. ?????, ????????, ?????-???? ?? ??????? ?? ???????? ?? ???? ???, ???? ?? ??? ?????? ???? ???? ??? ????? ??? ?? ???? ??. Microsoft ??????? ??? ???? ?? ?????? ?? ??????????, ????????? ?? ??? ?????? ?? ???? ????? ?? ???? ???????? ?? ??? ???? ????? ?? ??? ????????? ???? ??. Microsoft ????-?????? ?????????? ?? ????? ?????? ?? ?? ??? ??.
?????????? ?? ??????? ????????? ??????? ??:305199  (http://support.microsoft.com/kb/305199/en-us/ )