vb 操作excel, 如何在excel文件中写入值
比如说我想把vb的窗体上的textbox里的内容“好好学习,天天向上”插入在(3,4)单元里我想在窗体上有一个按钮,一按这个按钮,“好好学习,天天向上”就到了指定的exc...
比如说 我想把vb的窗体上的textbox里的内容“好好学习,天天向上”插入在(3,4)单元里
我想在窗体上有一个按钮,一按这个按钮,“好好学习,天天向上”就到了指定的excel里指定的单元里
谢谢
我要的是代码~~~ 展开
我想在窗体上有一个按钮,一按这个按钮,“好好学习,天天向上”就到了指定的excel里指定的单元里
谢谢
我要的是代码~~~ 展开
展开全部
Private Sub Command1_Click()
Dim xlExcel As Excel.Application
Dim xlBook As Excel.Workbook
Dim xlSheet As Excel.Worksheet
Dim AppExcel As Object
Dim str As String
str = App.Path & "\11.xls"
Set objExcel = CreateObject("Excel.Application")
objExcel.Visible = False '设置excel对象不可见
Dim objWorkBook As Excel.Workbook
objExcel.SheetsInNewWorkbook = 1
Set objWorkBook = objExcel.Workbooks.Add
objExcel.Cells(3,4) = Text1.Text
objWorkBook.SaveAs str
objWorkBook.Close (True)
objExcel.Quit
Set objExcel = Nothing
End Sub
Dim xlExcel As Excel.Application
Dim xlBook As Excel.Workbook
Dim xlSheet As Excel.Worksheet
Dim AppExcel As Object
Dim str As String
str = App.Path & "\11.xls"
Set objExcel = CreateObject("Excel.Application")
objExcel.Visible = False '设置excel对象不可见
Dim objWorkBook As Excel.Workbook
objExcel.SheetsInNewWorkbook = 1
Set objWorkBook = objExcel.Workbooks.Add
objExcel.Cells(3,4) = Text1.Text
objWorkBook.SaveAs str
objWorkBook.Close (True)
objExcel.Quit
Set objExcel = Nothing
End Sub
推荐律师服务:
若未解决您的问题,请您详细描述您的问题,通过百度律临进行免费专业咨询
广告 您可能关注的内容 |