投稿日 | : 2004/02/04(Wed) 16:55 |
投稿者 | : nobu |
Eメール | : |
URL | : |
タイトル | : Re: タイマーで |
適当な箇所で改行して下さい。
Sub data() の中で .Add したので次から次に
新しいExcelが開いてしまいます。
差し辺りは下記で如何でしょうか?
------------------------------
Option Explicit
Dim lngCounter As Long
Dim j As Integer
Dim X As Integer
Dim xlBook As Excel.Workbook
Dim xlSheet As Excel.Worksheet
Dim xlApp As Excel.Application
Private Sub Form_Load()
Set xlApp = CreateObject("Excel.Application")
Set xlBook = xlApp.Workbooks.Add
Set xlSheet = xlBook.Worksheets.Add
End Sub
Private Sub Command2_Click()
'終了用
Set xlSheet = Nothing
Set xlBook = Nothing
Set xlApp = Nothing
Unload Me
End Sub
Sub data()
j = 9 + X
xlSheet.Cells(j, 10) = lngCounter
X = X + 1
xlApp.Visible = True
End Sub
Private Sub Command1_Click()
If Timer1.Interval = 1000 Then
Timer1.Interval = 0
Else
Label1.Caption = ""
lngCounter = 0
X = 0
Timer1.Interval = 1000
End If
End Sub
Private Sub Timer1_Timer()
lngCounter = lngCounter + 1
Label1.Caption = lngCounter
Call data
End Sub