Friday, April 9, 2010

VBScript - Configure Worksheet Center Header

VBScript - Configure Worksheet Center Header (Sets the center header of every worksheet in a workbook to the worksheet name.)

On Error Resume Next

Set objExcel = CreateObject("Excel.Application")
set objWorkbook = objExcel.Workbooks.Open("c:\Scripts\Excel.xls")

objExcel.Visible = True

Count = objWorkbook.Worksheets.Count

For I = 1 To Count
Set objWorksheet = objWorkbook.Worksheets(I)
objWorksheet.pagesetup.centerheader = objworksheet.Name
Next

WScript.Echo "complete"

[Via]