Question : VBA error disables page layout

I have an Access function that writes data to an open spreadsheet.  I've been using this function without problems for two years, and it has worked for several months using Office 2007.

All of a sudden, I am getting an error when I attempt to access page setup information through VBA, and after I clear the error, the margin, orientation, page size, and breaks icons on the page layout tab of the ribbon are disabled, as is the litle icon at the bottom right that brings up the old style page setup dialog box.

The error I receive is: 1004 - Unable to set the CenterHeader property of the PageSetup class.

If I close the worksheet and then open a new worksheet (within the same Excel application) the page setup options are still disabled.  When I close and restart Excel, page setup returns to normal.

Any help is appreciated.

Thanks,
Scott


Here's the code I am running.
'======================
' Declare Excel objects
    Set objXL = GetObject(, "Excel.Application")
    Set objActiveWkb = objXL.Application.ActiveWorkbook
   
    With objActiveWkb
 
       'Create a new sheet in workbook and set up headers, column widths, etc.
        .Worksheets.Add.Move after:=.Worksheets(.Worksheets.Count)
        .ActiveSheet.Name = strMySheetName
        .ActiveSheet.Cells.Font.Name = "Arial"
        .ActiveSheet.Cells.Font.Size = 8
               
        With .ActiveSheet.PageSetup
            .CenterHeader = strMyCenterHeader            '**** HERE'S WHERE IT ERRORS OUT
            .TopMargin = objXL.InchesToPoints(0.75)
            .BottomMargin = objXL.InchesToPoints(0.5)
            .LeftMargin = objXL.InchesToPoints(0.5)
            .RightMargin = objXL.InchesToPoints(0.5)
        End With

'======================
Here are my versions of Excel

Excel 2007 Version   12.0.6323.5000
MSO SP1  Version     12.0.6213.1000        

'======================

Answer : VBA error disables page layout

Never mind - I found the problem.  Somewhere along the line, windows had switched my default printer to a text only printer which does not support page setup.  As a result, the properties were not modifiable.  Switching the default printer fixed the problem.
Random Solutions  
 
programming4us programming4us