General

6.48 Esempio di automazione con MSExcel.
  Federico Luciani
Private Sub cmdExcel_Click()
    'Autore: Federico Luciani
    Dim excApp As Object
    Dim excDoc As Object
    Dim blOpen As Boolean
    On Error Resume Next
    blOpen = True
    Set excApp = GetObject(, "Excel.Application")
    If Err.Number = 429 Then
        Set excApp = CreateObject("Excel.Application")
        blOpen = False
        Err.Number = 0
    End If
    On Error GoTo gestErrori
    Set excDoc = excApp.workbooks.Add
    excApp.Visible = True
    excDoc.Worksheets(1).Cells(2, 2) = "Hello World!"
    If Not blOpen Then
        excDoc.Close savechanges:=False
        excApp.Application.Quit
    End If
esci:
    Set excDoc = Nothing
    Set excApp = Nothing
    Exit Sub
gestErrori:
    MsgBox Err.Number & " - " & Err.Description
    GoTo esci
End Sub


Se pensate di avere del materiale freeware interessante e volete pubblicarlo, allora leggete qui.