#cs ---------------------------------------------------------------------------- AutoIt Version: 3.3.14.2 Author: myName Script Function: Template AutoIt script. #ce ---------------------------------------------------------------------------- #include ;Initializes GUI Library Constants #Include ;Initializes GUI Time Constants #Include ;Initializes GUI Array Library #include ;Initializes File Read Library #include ;Initializes File Library #include ;Initializes Button Library #include ;Initializes String Library #include ;Initializes DOS Commands #include ;Initialize Excel Library #include #include Global $oExcel = _Excel_Open() Global $FilePath = "C:\AutoIT\Flow Diagram.xlsx" Global $oWorkbook = _Excel_BookOpen($oExcel, $FilePath) Global $Shape_Type Global $shapObject Global $Connector_Type Global $ConnectorObject Global $Start_X Global $Start_Y Global $Shape_Name Global $Line_Weight = 1.0 Global $Line_Color = 0 Global $Step_Height = 36 Global $Step_Width = 72 Global $Trans_Height = 48 Global $Trans_Width = 72 Global $msoShapeFlowchartProcess = 61 Global $msoShapeFlowchartDecision = 63 Global $msoShapeFlowchartTerminator = 69 Global $msoShapeFlowchartOffpageConnector = 74 Global $msoConnectorElbow = 2 Global $msoConnectorStraight = 1 Global $msoAlignCenter = 2 Global $msoAnchorMiddle = 3 WinWaitActive($FilePath,"",10); Waits for file to open WinSetState("Flow Diagram - Excel","",@SW_SHOWMAXIMIZED) $oExcel.Sheets ("Flow_Diagram" ).Select ;Adds Step to Diagram $Shape_Type = $msoShapeFlowchartProcess $Start_X = 36 $Start_Y = 36 $Shape_Name = "Step1" AddShape_Function($Shape_Type, $Start_X, $Start_Y, $Shape_Name) ;Adds Transition to Diagram $Shape_Type = $msoShapeFlowchartDecision $Start_X = 36 $Start_Y = $Start_Y + 72 $Shape_Name = "Trans1" AddShape_Function($Shape_Type, $Start_X, $Start_Y, $Shape_Name) ;Adds Connector and connects Step to Transition $Connector_Type = $msoConnectorStraight $Begin_X = $Start_X $End_X = $Start_X + 36 $Begin_Y = $Start_Y - 72 $End_Y = $Start_Y $Begin_Name = "Step1" $End_Name = "Trans1" AddConnector_Function($Connector_Type, $Begin_X, $End_X, $Begin_Y, $End_Y, $Begin_Name, $End_Name) AddConnector_Function($Connector_Type, $Begin_X, $End_X, $Begin_Y, $End_Y, $Begin_Name, $End_Name) Func AddShape_Function($Shape_Type, $Start_X, $Start_Y, $Shape_Name) $oExcel.Sheets ("Flow_Diagram" ).Select With $oExcel .ActiveSheet.Shapes.AddShape($Shape_Type, $Start_X, $Start_Y, $Step_Width, $Step_Height).Select ;Shape type, X location, Y location, width, height $shapObject = .Selection.ShapeRange $shapObject.Name = $Shape_Name If $Shape_Type <> $msoShapeFlowchartDecision Then $shapObject.Width = $Step_Width $shapObject.Height = $Step_Height Else $shapObject.Width = $Trans_Width $shapObject.Height = $Trans_Height EndIf $shapObject.Fill.Visible = False $shapObject.Line.Visible = True $shapObject.Line.Weight = $Line_Weight $shapObject.Line.ForeColor.SchemeColor = $Line_Color $shapObject.TextFrame2.TextRange.Characters.Font.Fill.Visible = True $shapObject.TextFrame2.TextRange.Characters.Font.Fill.ForeColor = 0 $shapObject.TextFrame2.TextRange.Characters.Text = $Shape_Name $shapObject.TextFrame2.TextRange.Font.Fill.Visible = True $shapObject.TextFrame2.TextRange.Font.Fill.ForeColor.RGB = 0 $shapObject.TextFrame2.TextRange.ParagraphFormat.Alignment = $msoAlignCenter $shapObject.TextFrame2.VerticalAnchor = $msoAnchorMiddle $shapObject.TextFrame2.AutoSize = 0 $shapObject.TextFrame.VerticalOverflow = 0 EndWith EndFunc Func AddConnector_Function($Connector_Type, $Begin_X, $End_X, $Begin_Y, $End_Y, $Begin_Name, $End_Name) $oExcel.Sheets ("Flow_Diagram" ).Select Local $Connector_Name = $Begin_Name & "_To_" & $End_Name With $oExcel $BeginObject = .ActiveSheet.Shapes.Range($Begin_Name) $EndObject = .ActiveSheet.Shapes.Range($End_Name) .ActiveSheet.Shapes.AddConnector($Connector_Type, $Begin_X, $End_X, $Begin_Y, $End_Y).Select ;Connector type, Begin X location, End X location, Begin Y location, End Y location $ConnectorObject = .Selection.ShapeRange $ConnectorObject.Name = $Connector_Name $BeginObject.Select $ConnectorObject.ConnectorFormat.BeginConnect = $BeginObject.Name & ", " & 3 $EndObject.Select $ConnectorObject.ConnectorFormat.EndConnect = $EndObject.Name & ", " & 1 $ConnectorObject.Select $ConnectorObject.RerouteConnections EndWith EndFunc