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

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


留言列表 (1)

發表留言
  • 石頭
  • 謝謝~~~受益良多 ^^