Archive

Archive for March, 2015

Refresh Multiple Excel files in a filder using Powershell

$libraryPath = "\\Shared\Reports"
$allExcelfiles = Get-ChildItem -path $libraryPath -include *.xlsx, *.xls;

foreach ($file in $allExcelfiles)
{
$excel = new-object -comobject Excel.Application
$excel.Visible = $false
$excel.displayAlerts = $false
Start-Sleep -s 1

Write-Host "$file"
$workbookpath = $file.fullname
$excelworkbook = $excel.workbooks.Open($workbookpath)
Start-Sleep -s 1

$excelworkbook.RefreshAll()
Start-Sleep -s 1

$excelworkbook.Save()
Start-Sleep -s 1

$excel.quit()
Start-Sleep -s 1
}

Categories: Uncategorized