VB写入EXCEL的问题读取一个文件内容为:
"1
2
3
"
当我写入EXCEL表中会出现A列下的
"1
2
3
"
但我想下次再输入时候新数据在B列下
以下是我输入的代码,我想过用APPEND,但效果出来是在A列下继续写下去
DIM a(30) as string ,i as integer
Open App.Path & "\123.xls" For Output As #1
a(i) = Text1.Text
Print #1, a(i)
"1
2
3
"
当我写入EXCEL表中会出现A列下的
"1
2
3
"
但我想下次再输入时候新数据在B列下
以下是我输入的代码,我想过用APPEND,但效果出来是在A列下继续写下去
DIM a(30) as string ,i as integer
Open App.Path & "\123.xls" For Output As #1
a(i) = Text1.Text
Print #1, a(i)
通用程序是
Function ReturnxlSheet(InputSheetName As String) As Worksheet
Dim xlApp As Application ' This Line ,Not set Excel , run Excel
'Dim xlsheet As Object
' 发生错误时跳到下一个语句继续执行
On Error Resume Next
' 连接Excel应用程序
Set xlApp = GetObject(, "Excel.Application")
' Debug.Print Err.Number
If Err.Number <> 0 Then
Set xlApp = CreateObject("Excel.Application")
xlApp.Visible = True
xlApp.Workbooks.Add
End If ' 返回当前活动的工作表
Set ReturnxlSheet = xlApp.Worksheets(InputSheetName)
xlApp.Worksheets(InputSheetName).Activate
End Function
Open App.Path & "\123.xls" For Output As #1 只见过在文本处理时用.