zedman3d
Fully Optimized
- Messages
- 2,850
Code:
Private Sub cmdCheck1_Click()
'Add a reference to MS Excel xx.0 Object Library
Dim oApp As Excel.Application
Dim oWB As Excel.Workbook
Dim oXLSheet As Excel.Worksheet
'Create an Excel instalce.
Set oApp = New Excel.Application
'Open the desired workbook
Set oWB = oApp.Workbooks.Open(FileName:="G:\Book1.xls")
'Open specifc sheet
Set oXLSheet = oWB.Worksheets(1)
'Do any modifications to the workbook.
'...
oXLSheet.Cells(2, 1).Value = "hello"
'Save the xls file
oWB.SaveAs FileName:="G:\Book1_MOD.xls"
'close and clean up resources
oWB.Close SaveChanges:=False
Set oWB = Nothing
oApp.Quit
Set oApp = Nothing
End Sub
What have i done wrong? Nothing happens at all.
Thank you.