|
-
Aug 23rd, 2000, 06:40 PM
#1
Thread Starter
New Member
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.
-
Aug 23rd, 2000, 07:52 PM
#2
Lively Member
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
-
Aug 24th, 2000, 07:56 AM
#3
Thread Starter
New Member
I will give it a try.
Thank you very much for your time.
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|