Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations TouchToneTommy on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Error with Win2000 and Excel 97 1

Status
Not open for further replies.

ColinC

Programmer
Apr 12, 2000
29
CA
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) <> &quot;)&quot;
x = x + 1
Loop
strTitle = Left(strTitle, x)
strTitle = strTitle & Chr(13)

x = 1
Do While Cells(3, x) <> &quot;&quot;
strTitle = strTitle & &quot; &quot; & Cells(3, x)
x = x + 1
Loop

With ActiveSheet
.PageSetup.CenterHeader = &quot;&B&quot; & strTitle
.PageSetup.RightFooter = &quot;Page &P of &N&quot;
Application.DisplayAlerts = False
.Range(Cells(1, 1), Cells(4, 1)).EntireRow.Delete (xlShiftUp)
.Range(&quot;A1&quot;).EntireColumn.Delete
End With

Rows(&quot;1:1&quot;).Select
Rows(&quot;1:1&quot;).Font.Bold = True
Range(&quot;A1:N1&quot;).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

 
Have you tried recording yourself doing a page setup with headers and footers in all the relevant areas ? Might be worth a try to see what excel spits out.
HTH
Geoff
 
Are there printer drivers missing on this system?

HTH

Indu
 
Excel generates the same thing. I'm still looking into the printer drivers.

With ActiveSheet.PageSetup
.LeftHeader = &quot;&quot;
.CenterHeader = &quot;This is a test&quot;
.RightHeader = &quot;&quot;
.LeftFooter = &quot;&quot;
.CenterFooter = &quot;&quot;
.RightFooter = &quot;&quot;
.LeftMargin = Application.InchesToPoints(0.75)
.RightMargin = Application.InchesToPoints(0.75)
.TopMargin = Application.InchesToPoints(1)
.BottomMargin = Application.InchesToPoints(1)
.HeaderMargin = Application.InchesToPoints(0.5)
.FooterMargin = Application.InchesToPoints(0.5)
.PrintHeadings = False
.PrintGridlines = False
.PrintComments = xlPrintNoComments
.PrintQuality = 600
.CenterHorizontally = False
.CenterVertically = False
.Orientation = xlPortrait
.Draft = False
.PaperSize = xlPaperLetter
.FirstPageNumber = xlAutomatic
.Order = xlDownThenOver
.BlackAndWhite = False
.Zoom = 100
End With Colin Chevrier
Colin_Chevrier@consulting.fujitsu.com

 
All the machines generating the error except 1 had no printers installed. Once the printers were set up the problem was solved. The one machine with the printer already installed that was getting the error used to run the code fine. It's a laptop and it might have been rebooted without being connected to the network.

Thanks for the help Indu. A star for you. Colin Chevrier
Colin_Chevrier@consulting.fujitsu.com

 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top