Home |
Search |
Today's Posts |
#1
![]()
Posted to microsoft.public.excel.programming
|
|||
|
|||
![]()
Need VBS script to clear the contents for range all worksheets in workbook.
Must run as VBS script. Having issue with line "currentWorkSheet .Range( cellRange ).ClearContents"; error generated excelPath = "<Enter a UNC path to a workbook with 1+ worksheets" cellRange = "A1:Z100" WScript.Echo "Reading Data from " & excelPath WScript.Echo "cellRange = " & cellRange Set oExcel = CreateObject("excel.application") oExcel.Workbooks.open( excelPath ) workSheetCount = oExcel.Worksheets.Count WScript.Echo "We have " & workSheetCount & " worksheets" For counter = 1 to workSheetCount WScript.Echo "Reading data from worksheet " & counter & vbCRLF Set currentWorkSheet = oExcel.ActiveWorkbook.Worksheets( counter ) WScript.Echo "Call to Range method next" & vbCrLf currentWorkSheet .Range( cellRange ).ClearContents ' <-- Fails Set currentWorkSheet = Nothing Next oExcel.Workbooks(1).Close oExcel.Quit Set currentWorkSheet = Nothing Set oExcel = Nothing |
Thread Tools | Search this Thread |
Display Modes | |
|
|
![]() |
||||
Thread | Forum | |||
Find Throws Error 91 | Excel Programming | |||
workbook.open throws 1004 error | Excel Programming | |||
How do I perform a certain function if VBA throws up an error? | Excel Programming | |||
[Q] Save As throws type mismatch error in control's code? | Excel Discussion (Misc queries) | |||
Format statement no longer throws an error | Excel Programming |