If this is your first visit, be sure to check out the FAQ by clicking the link above. You may have to register before you can post: click the register link above to proceed. To start viewing messages, select the forum that you want to visit from the selection below.

 
Go Back  dBforums > Database Server Software > Microsoft SQL Server > ActiveX script to clear contents in Excel

Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1 (permalink)  
Old 06-10-03, 14:40
mkal mkal is offline
Registered User
 
Join Date: May 2003
Posts: 60
ActiveX script to clear contents in Excel

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.
Reply With Quote
Reply

Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On