I'm looking to clear the contents on an excel spreadsheet before importing new data from an access database. The workbook and spreadhsheet have already been created with a specific format so I must use it.
I've been trying to get an ActiveX script to open the workbook and clearthe contents on a given sheet but have so far been unsuccessful.
I've started my script like below just to see if I can open the workbook,
Function Main()
Dim oSSBExcelWbook
Set oSSBExcelWbook = CreateObject( "Excel.Application.10")
oSSBExcelWbook.Open ("C:\SSB\Reports_Pivottables\TestSSB1.xls")
oSSBExcelWbook.Visible = True
After I plan on using something like below for each sheet in the workbook.
Range("b2").Activate
ActiveCell.CurrentRegion.Select
Cells.ClearContents
Main = DTSTaskExecResult_Success
End Function
but it fails with the error message:
Error Source: Microsoft Data Transformation Services(DTS)Package
Error Description: Error Code 0
Error Source=Microsoft VBScript runtime error
Error Description: Object doesn't support this property or method oSSBExcelWbook.Open
Would appreciate any and all suggestions.