Submitted By: Kent Finkle

Puts the current date, current time, and the current page and total pages into an Excel spreadsheet.

PowerShell
Edit|Remove
$comments = @'
Script name: Change-Footer.ps1
Created on: Thursday, April 12, 2007
Author: Kent Finkle
Purpose: How can I use Windows Powershell to Change the Footer in an Excel Spreadsheet?
'@

# -----------------------------------------------------
function Release-Ref ($ref) {
([System.Runtime.InteropServices.Marshal]::ReleaseComObject(
[System.__ComObject]$ref) -gt 0)
[System.GC]::Collect()
[System.GC]::WaitForPendingFinalizers()
}
# -----------------------------------------------------

$objExcel = new-object -comobject excel.application 
$objExcel.Visible = $True 
$objWorkbook = $objExcel.Workbooks.Add() 
$objWorksheet = $objWorkbook.Worksheets.Item(1)

$objWorksheet.PageSetup.LeftFooter = "&D"
$objWorksheet.PageSetup.CenterFooter = "Page &P of &N"
$objWorksheet.PageSetup.RightFooter = "&T"

$a = Release-Ref($objExcel)