Sub defineNewField() Dim g As Graphic Dim p As Property Set g = ActiveDrawing.Graphics.AddLineSingle(0, 0, 0, 100, 0, 0) 'example graphic Set p = g.Properties.Add("Cost", CCur(0), False) Set p = Nothing Set g = Nothing End Sub
Sub SumTotalCost() MsgBox FindTotalCost End Sub
Sub SumSelectionCost() On Error Resume Next Dim s As Selection Dim Totcost As Currency Totcost = 0 Set s = ActiveDrawing.Selection For i = 0 To s.Count - 1 Totcost = Totcost + CCur(s.Item(i).Properties("Cost").Value) Next i Set s = Nothing MsgBox Totcost End Sub
Sub makeCSVfile() Dim s As String On Error Resume Next Open Application.Path & "\testCSV.txt" For Output As #1 Dim g As Graphic For Each g In ActiveDrawing.Graphics s = "Test," & g.Properties("DatabaseID").Value & "," & CStr(g.Properties("Cost").Value) Print #1, s Set g = Nothing Next g Print #1, "Total Cost," & CStr(FindTotalCost) Close #1 MsgBox "Exported:" & Application.Path & "\testCSV.txt" End Sub
Private Function FindTotalCost() As Currency On Error Resume Next Dim Totcost As Currency Totcost = 0 Dim g As Graphic For Each g In ActiveDrawing.Graphics Totcost = Totcost + CCur(g.Properties("Cost").Value) Set g = Nothing Next g FindTotalCost = Totcost End Function