Article ID: 124494
Article Last Modified on 10/11/2006
' This procedure creates a new workbook, enters some numbers in a
' worksheet, creates a chart, rotates the chart, and then closes
' Microsoft Excel.
Sub SpinIt()
Dim ExcelChart As Object
Dim i As Integer
'Create a new workbook, type in three numbers, create a chart,
'and change the chart type to 3-D Column
Workbooks.Add
Range("a1").Value = 3
Range("a2").Value = 2
Range("a3").Value = 1
Range("a1:a3").Select
Set ExcelChart = Charts.Add()
ExcelChart.Type = xl3DColumn
'Rotate chart
For i = 30 To 180 Step 10
ExcelChart.Rotation = i
Next
'Close all open files and quit Microsoft Excel.
Application.DisplayAlerts = False
ActiveWorkbook.Close (False)
Application.Quit
End Sub
Sub Command2_Click ()
Dim ExcelApp As Object
'Opens Excel OLE Object
Set ExcelApp = CreateObject("excel.application")
ExcelApp.Visible = True
'Opens the previously saved Excel workbook and runs the macro
ExcelApp.Workbooks.Open ("c:\vb3ole.xls")
ExcelApp.run ("spinit")
Set ExcelApp = Nothing
End
End Sub
Additional query words: XL5
Keywords: kbinterop kbprogramming KB124494