I am trying to get to grips with object heirarchy
Could someone please let me know why the following work/ don't work (as noted in the comments) before I loose my marbles completely - any insight would be appreciated:
Many thanks - Alastair
.
.
Set AppExcel = CreateObject("Excel.Application")
set wBook = AppExcel.Workbooks.Open("Temp.xls")
Set mysheet = wBook.Sheets(1)
.
.
wBook.WorkSheets(1).Select
wBook.WorkSheets(1).Activate
'These lines performs without error
AppExcel.Range("A2").Select
AppExcel.Range(AppExcel.Selection, AppExcel.Selection.End(xlDown)).Select
AppExcel.Selection.ClearContents
'I thought the following would be equivalent to the above lines - the middle line Fails on error 'Object variable or With block variable not set
With mysheet
.Range("A2").Select
.Range(Selection, Selection.End(xlDown)).Select 'Fails on error 'Object variable or With block variable not set
.Cells.ClearContents
End With