Forum Discussion
Power Query when add a new excel files to a folder and get Error
- 3 years ago
hi mahenkj2
after read the post on the link shared, that I thank you.
I've noticed that the problem can be solved just by open and close the EXCEL file, without any change or editing. So, following an example on one of the reply related to the shared post, I've adapt a powershell script, that I run each time that any new files is placed into any subfolder. After I can refresh all in the PowerBI without having the error
$fileList = Get-ChildItem -path "C:\anydirectory" -Recurse| %{$_.FullName}
$excelComObject = New-Object -COM "Excel.Application"
$excelComObject.DisplayAlerts = $falseforeach ($file in $fileList) {
$file
$wb = $excelComObject.Workbooks.Open($file, $true, $false)
$wb.Save()
$wb.Close()
}$excelComObject.Quit()
[System.Runtime.Interopservices.Marshal]::ReleaseComObject($excelComObject)
Remove-Variable excelComObjectThanks
hi mahenkj2
after read the post on the link shared, that I thank you.
I've noticed that the problem can be solved just by open and close the EXCEL file, without any change or editing. So, following an example on one of the reply related to the shared post, I've adapt a powershell script, that I run each time that any new files is placed into any subfolder. After I can refresh all in the PowerBI without having the error
$fileList = Get-ChildItem -path "C:\anydirectory" -Recurse| %{$_.FullName}
$excelComObject = New-Object -COM "Excel.Application"
$excelComObject.DisplayAlerts = $false
foreach ($file in $fileList) {
$file
$wb = $excelComObject.Workbooks.Open($file, $true, $false)
$wb.Save()
$wb.Close()
}
$excelComObject.Quit()
[System.Runtime.Interopservices.Marshal]::ReleaseComObject($excelComObject)
Remove-Variable excelComObject
Thanks