About to throw myself off the building on this one.
What I am tryong to do:
create a var for month, day and year (no problem and working)
open a excel workbook (no problem and working)
once open
select a worksheet in the workbook (not working)
I've tried the following (and diferent variants)
$excelFilePath = "C:\myfile.xls"
$excel = New-Object -comobject Excel.Application
$excel.Visible = $TRUE
$workbook = $excel.Workbooks.Open($excelFilePath)
$worksheet = $workbook.worksheets.Item(1)
For some reason the $worksheet = $workbook.worksheets.Item(1) is not behaving like I thought it would. Item(1) doesnt do anything. For me it's always opening on the 6th worksheet no matter what.
if I change the Item(1) to (2) = nothing, stills open with the 6th worksheet active
I've tried other things like:
worksheets.select(1)
worksheets.item(1).select
plus many other weird things that I knew wouldnt even work.
can anyone point me in the right direction.
I just need to select a worksheet once my excel doc is open.
Phil