-
I created a command button in VB6. In the click event I put the following code.
Dim objExcel As Object
Set objExcel = GetObject("C:\Dave.xls")
objExcel.Application.Cells(1,1).Value = 7
((help))
objExcel.Application.Quit
Set objExcel = Nothing
On the line that I wrote ((help)) I have been trying to find some code to save
the file Dave.xls.
My goal is to find some code to put in the command button such that when pressed
it opens an Excel spreadsheet, writes 7 to cell 1,1, saves the file, the closes
Excel.
Thank you for taking the time to read this.
Any help you can offer would be very much appreciated.
Dave7.
-
try this
(you will need to add the excel library in the project references)
Private Sub Command1_Click()
Dim appXL As Excel.Application
Set appXL = CreateObject("Excel.Application")
With appXL
.Workbooks.Open FileName:="C:\temp.xls"
.activesheet.Cells(1, 1).Value = 7
.activeworkbook.save
.quit
End With
Set appXL = Nothing
End Sub
-
I will give it a try.
Thank you very much for your time.