Sub Main 'Declares GrapherApp as an object Dim GrapherApp As Object 'Creates an instance of the Grapher Application object 'and assigns it to the variable named "GrapherApp" Set GrapherApp = CreateObject("Grapher.Application") 'Make Grapher visible GrapherApp.Visible = True 'Declare Docs as Object Dim Docs As Object 'Assigns the Documents collection to the 'variable named "Docs" Set Docs = GrapherApp.Documents 'Declare Plot As Object Dim Plot As Object 'Creates a new plot window and assigns it 'to the variable named "Plot" Set Plot = Docs.Add(grfPlotDoc) 'Declare Shapes As Object Dim Shapes As Object 'Assigns the AutoShapes collection to the 'variable named "Shapes" Set Shapes = Plot.Shapes 'Add LinePlotGraph Dim Graph1 As Object Set Graph1 = Shapes.AddLinePlotGraph(GrapherApp.Path + "\samples\sample3.dat") Set Line1 = Graph1.Plots(1) 'Add second line plot Set Line2 = Graph1.AddLinePlot(GrapherApp.Path + "\samples\sample3.dat",1,3) 'Change Line color for Line2 Line2.line.foreColor = grfColorBlue 'Set XAxis to the first X axis on the graph Set XAxis = Graph1.Axes("X Axis 1") 'Set the XAxis to use date/time labels XAxis.TickLabels.UseDateTimeFormat = True 'Change the Date/time format XAxis.TickLabels.MajorFormat.DateTimeFormat = 11 'Open the worksheet Set Wks = Docs.Open(GrapherApp.Path + "\samples\sample3.dat") 'Read column headings -- Y columns, row 1 Line1Text = Wks.Cells("B1").Value Line2Text = Wks.Cells("C1").Value 'Add a legend Set Legend1 = Graph1.AddLegend(True) 'Change the text of the legend line text to show the column name Legend1.EntryName(1) = Line1Text Legend1.EntryName(2) = Line2Text 'Export to a TIF that contains the same name as the data file name Plot.Export(Left(Wks.FullName,Len(Wks.FullName)-3)+"TIF") End Sub