急求,谁能告诉我,如何在用vb 6.0 创建的程序中,每次打开都能创建一个新的EXCEL文件呢?
该程序实现的是要把实时采集的鼠标数据写入连接的excel数据库。要求每次打开该程序,都能在相应的文件夹中自动创建一个excel文件,并且能把采集的数据写入其中~...
该程序实现的是要把实时采集的鼠标数据写入连接的excel数据库。要求每次打开该程序,都能在相应的文件夹中自动创建一个excel文件,并且能把采集的数据写入其中~
展开
1个回答
展开全部
自动记录鼠标点。当然可是别的什么信息:
Private Declare Function GetCursorPos Lib "user32" (lpPoint As POINTAPI) As Long
Public xlApp As Excel.Application
Public xlbook As Excel.Workbook
Public xlSheet As Excel.Worksheet
Dim i As Integer
Private Type POINTAPI
X As Long
Y As Long
End Type
Private Sub Form_Load()
CreateExcel
End Sub
Private Sub Timer1_Timer()
writeData
End Sub
Public Function CreateExcel()
Set xlApp = CreateObject("excel.application")
Set xlbook = xlApp.Workbooks.Add
Set xlSheet = xlbook.Worksheets(1)
xlApp.Visible = True
End Function
Public Function writeData()
Dim biao As POINTAPI
GetCursorPos biao
i = i + 1
xlSheet.Cells(i, 1).Value = biao.X
xlSheet.Cells(i, 2).Value = biao.Y
xlApp.DisplayAlerts = False
xlbook.SaveAs "d:\zzc.xlsx"
End Function
Public Function quitExcel()
xlApp.Quit
Set xlApp = Nothing
Set xlbook = Nothing
End Function
张志晨
Private Declare Function GetCursorPos Lib "user32" (lpPoint As POINTAPI) As Long
Public xlApp As Excel.Application
Public xlbook As Excel.Workbook
Public xlSheet As Excel.Worksheet
Dim i As Integer
Private Type POINTAPI
X As Long
Y As Long
End Type
Private Sub Form_Load()
CreateExcel
End Sub
Private Sub Timer1_Timer()
writeData
End Sub
Public Function CreateExcel()
Set xlApp = CreateObject("excel.application")
Set xlbook = xlApp.Workbooks.Add
Set xlSheet = xlbook.Worksheets(1)
xlApp.Visible = True
End Function
Public Function writeData()
Dim biao As POINTAPI
GetCursorPos biao
i = i + 1
xlSheet.Cells(i, 1).Value = biao.X
xlSheet.Cells(i, 2).Value = biao.Y
xlApp.DisplayAlerts = False
xlbook.SaveAs "d:\zzc.xlsx"
End Function
Public Function quitExcel()
xlApp.Quit
Set xlApp = Nothing
Set xlbook = Nothing
End Function
张志晨
更多追问追答
追问
高手啊,这么快~
求教下,按照你这个程序我试了一试,总是在第二行出现用户定义类型未定义,这是什么意思?
在窗体上我只需要加一个timer控件对么?
追答
引用Excel 14.0
推荐律师服务:
若未解决您的问题,请您详细描述您的问题,通过百度律临进行免费专业咨询