Hello team,
I had this piece of code that works in PWS 2.0 but no more in 3.0
$oXl = New-Object -comobject Excel.Application
$oXl.Visible = $false
$oXl.displayalerts=$false
$Workbook = $oXl.Workbooks.Open($XlFile)
$sheet = $workbook.worksheets.item("Data")
$sheet.QueryTables.count
$Qtable=$sheet.QueryTables.item(1)
$Qtable.name
$Qtable.Delete()
$sheet.QueryTables.count
$sheet.Columns.item('A:Z').clear()
$querytable=$sheet.QueryTables.Add("TEXT;c:\usr\output\FinLM.txt",$sheet.Range('$A:$K'))
$querytable.Refresh()
$sheet.QueryTables.count
$querytable.name
$Workbook.Save()
In V3 I get the following error after $querytable=$sheet.QueryTables.Add("TEXT;c:\usr\output\FinLM.txt",$sheet.Range('$A:$K')) :
Exception getting "Range": "Exception from HRESULT: 0x800A03EC"
At C:\usr\bin\Top.ps1:193 char:2
+ $querytable=$sheet.QueryTables.Add("TEXT;c:\usr\output\By ...
+ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
+ CategoryInfo : NotSpecified: (:) [], GetValueInvocationException
+ FullyQualifiedErrorId : CatchFromBaseAdapterParameterizedPropertyGetValueTI
Anyone of you may have some idea?