Skip to content

Instantly share code, notes, and snippets.

@matt40k
Created November 20, 2018 10:36
Show Gist options
  • Save matt40k/9c770234bbd5497a64f532a4a17c4cd6 to your computer and use it in GitHub Desktop.
Save matt40k/9c770234bbd5497a64f532a4a17c4cd6 to your computer and use it in GitHub Desktop.
Update the data in Excel files
$dir = "c:\temp\" + (Get-Date).ToString("yyyy-MM-dd")
Write-Host $dir
$excelObj = New-Object -ComObject Excel.Application
$excelObj.Visible = $true
$files = Get-ChildItem -Path $dir
foreach ($file in $files)
{
$filePath = $file.FullName
$workBook = $excelObj.Workbooks.Open($filePath)
$workBook.RefreshAll()
$workBook.Save()
$workBook.Close()
}
$excelObj.Quit()
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment