I have several macros which use the following code:
Private Sub FormatHeader()
Dim strTitle As String
Dim x As Integer
x = 1
strTitle = Trim(Cells(1, 1).Value)
Do While Mid(strTitle, x, 1) <> "
"
x = x + 1
Loop
strTitle = Left(strTitle, x)
strTitle = strTitle & Chr(13)
x = 1
Do While Cells(3, x) <> ""
strTitle = strTitle & " " & Cells(3, x)
x = x + 1
Loop
With ActiveSheet
.PageSetup.CenterHeader = "&B" & strTitle
.PageSetup.RightFooter = "Page &P of &N"
Application.DisplayAlerts = False
.Range(Cells(1, 1), Cells(4, 1)).EntireRow.Delete (xlShiftUp)
.Range("A1"
.EntireColumn.Delete
End With
Rows("1:1"
.Select
Rows("1:1"
.Font.Bold = True
Range("A1:N1"
.Select
With Selection
.Font.Color = RGB(0, 0, 255)
.HorizontalAlignment = xlCenter
.WrapText = True
End With
End Sub
I get 'Unable to set the CenterHeader property of the PageSetup class' when I try to run it on Windows2000 Pro with Excel 97 SR2. The code runs on Win98 and NT with Excel97 and on Windows2000 Pro with Excel 2000. If anyone has any ideas why this is happening or how to get around it I would be very grateful. Colin Chevrier
Colin_Chevrier@consulting.fujitsu.com
Private Sub FormatHeader()
Dim strTitle As String
Dim x As Integer
x = 1
strTitle = Trim(Cells(1, 1).Value)
Do While Mid(strTitle, x, 1) <> "
x = x + 1
Loop
strTitle = Left(strTitle, x)
strTitle = strTitle & Chr(13)
x = 1
Do While Cells(3, x) <> ""
strTitle = strTitle & " " & Cells(3, x)
x = x + 1
Loop
With ActiveSheet
.PageSetup.CenterHeader = "&B" & strTitle
.PageSetup.RightFooter = "Page &P of &N"
Application.DisplayAlerts = False
.Range(Cells(1, 1), Cells(4, 1)).EntireRow.Delete (xlShiftUp)
.Range("A1"
End With
Rows("1:1"
Rows("1:1"
Range("A1:N1"
With Selection
.Font.Color = RGB(0, 0, 255)
.HorizontalAlignment = xlCenter
.WrapText = True
End With
End Sub
I get 'Unable to set the CenterHeader property of the PageSetup class' when I try to run it on Windows2000 Pro with Excel 97 SR2. The code runs on Win98 and NT with Excel97 and on Windows2000 Pro with Excel 2000. If anyone has any ideas why this is happening or how to get around it I would be very grateful. Colin Chevrier
Colin_Chevrier@consulting.fujitsu.com