Private Sub Command1_Click()
    FileName = App.Path & "\test.xls"
    If Dir(FileName) <> "" Then Kill FileName

    Dim myExcel As Object
    Set myExcel = CreateObject("excel.application")
    myExcel.Visible = True
    myExcel.Workbooks.Add 
    For i = 1 To 10
        myExcel.ActiveSheet.Cells(i, 1) = i
        myExcel.ActiveSheet.Cells(i, 2) = "列號的 10 倍是 " & i * 10
    Next
    myExcel.ActiveWorkbook.SaveAs FileName
    myExcel.Quit
    Set myExcel = Nothing
End Sub


arrow
arrow
    全站熱搜

    Roger 發表在 痞客邦 留言(1) 人氣()