Public Sub WriteToExcel()

    Dim objExcel As Excel.Application

    Dim objWb As Excel.Workbook

    Dim objPath As String

    objPath = CurrentProject.Path & "\excel_demo.xls"

    Set objExcel = CreateObject("Excel.Application")

    Set objWb = objExcel.Workbooks.Add

    objWb.Worksheets(1).Range("A1") = 5

    objWb.SaveAs objPath

    objExcel.Quit

    Set objExecel = Nothing

    Set objWb = Nothing

   

End Sub