[VBA] Found source of corruption, how do I remove /xl/printerSettings/printerSettings1.bin from file?

RockandGrohl

Well-known Member
Joined
Aug 1, 2018
Messages
801
Office Version
  1. 365
Platform
  1. Windows
Hi all, have a very macro heavy and business critical worksheet that is corrupting multiple times daily since an office move. It seems to be centred around the PrinterSettings component, which makes sense seeing as all our print setup has changed due to the new office.


We work in 2010 and it wasn't being verbose, but after attempting to open and then repairing the file on my home 365 setup, it gives me the following:

Excel completed file level validation and repair. Some parts of this workbook may have been repaired or discarded.
Removed Part: /xl/printerSettings/printerSettings1.bin part. (Print options)

If I rename the file from Price Panels 2021.xlsm to Price Panels 2021.zip, then go into the file and delete the PrinterSettings1-10.bin files, I can then open the sheet happily without needing to repair and this seems to solve the problem. But I fear that this is only temporary and the printer settings will return, so I'm asking is there a way to permanently remove these PrinterSettings files? Thank you.
 

Excel Facts

How to total the visible cells?
From the first blank cell below a filtered data set, press Alt+=. Instead of SUM, you will get SUBTOTAL(9,)
A little bit of searching seems to suggest that very long strings (> 255) are the problem. Do you have any very long strings in, say, the page setup area? If so, maybe reducing them would solve your problem.
 
Upvote 0
A little bit of searching seems to suggest that very long strings (> 255) are the problem. Do you have any very long strings in, say, the page setup area? If so, maybe reducing them would solve your problem.

Sorry, where is the Page Setup area?
 
Upvote 0
Do you have any code that looks like:
VBA Code:
        With .PageSetup
            .LeftHeader = vbNullString
            .CenterHeader = "My extremely long header that just goes on and on, never stopping, until it eventually gets so long that it exceeds 255 characters and starts causing a lot of problems that I really didn't want to have, but now corrupt my workbook and stress me out causing headaches, nervous tics, and dyspepsia"
            .RightHeader = vbNullString
            .LeftFooter = "&10&B&B" & Format(Date, "Short Date")
            .CenterFooter = vbNullString
            .RightFooter = "&10Page: &P of &N"
        End With
 
Upvote 0
No, there is no Pagesetup code anywhere in the whole project unfortunately.
 
Upvote 0
Take a look at the headers and footers that have been set for each worksheet.
 
Upvote 0
Take a look at the headers and footers that have been set for each worksheet.

Can I be an absolute eejit and ask for some more in depth guidance on this :P This is a sheet I've inherited and I haven't ever set page properties or headers and footers before, thanks.
 
Upvote 0
Of course. Run the following code on a copy of the workbook to clear all headers and footers:

VBA Code:
Sub ClearHeadersAndFooters()
    Dim wks As Worksheet
    For Each wks In ThisWorkbook.Worksheets
        With wks.PageSetup
            .LeftHeader = vbNullString
            .CenterHeader = vbNullString
            .RightHeader = vbNullString
            .LeftFooter = vbNullString
            .CenterFooter = vbNullString
            .RightFooter = vbNullString
        End With
    Next
End Sub

Then save and close the copy, and re-open it. Does the problem still exist?

And, for future reference, to manually change headers or footers for each worksheet:
1. Click on "Page Layout" in the ribbon.
2. In the "Page Setup" section, click the little arrow in a square that is in the bottom right of that section.
3. In the dialog box that comes up, click the "Header/Footer" tab.
4. Click the "Custom Header" button to see the headers, or the "Custom Footer" button to see the footers.
 
Upvote 0
Of course. Run the following code on a copy of the workbook to clear all headers and footers:

VBA Code:
Sub ClearHeadersAndFooters()
    Dim wks As Worksheet
    For Each wks In ThisWorkbook.Worksheets
        With wks.PageSetup
            .LeftHeader = vbNullString
            .CenterHeader = vbNullString
            .RightHeader = vbNullString
            .LeftFooter = vbNullString
            .CenterFooter = vbNullString
            .RightFooter = vbNullString
        End With
    Next
End Sub

Then save and close the copy, and re-open it. Does the problem still exist?

And, for future reference, to manually change headers or footers for each worksheet:
1. Click on "Page Layout" in the ribbon.
2. In the "Page Setup" section, click the little arrow in a square that is in the bottom right of that section.
3. In the dialog box that comes up, click the "Header/Footer" tab.
4. Click the "Custom Header" button to see the headers, or the "Custom Footer" button to see the footers.

Thanks, I'll give this a shot next time I'm in the worksheet.

So this was never an issue before, these sheets are used practically all day, by multiple users, and it only seems to have cropped up since the office moved to a new location. Do you have any ideas what might be triggering the corruption? Cheers.
 
Upvote 0
Upvote 0

Forum statistics

Threads
1,223,888
Messages
6,175,215
Members
452,618
Latest member
Tam84

We've detected that you are using an adblocker.

We have a great community of people providing Excel help here, but the hosting costs are enormous. You can help keep this site running by allowing ads on MrExcel.com.
Allow Ads at MrExcel

Which adblocker are you using?

Disable AdBlock

Follow these easy steps to disable AdBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the icon in the browser’s toolbar.
2)Click on the "Pause on this site" option.
Go back

Disable AdBlock Plus

Follow these easy steps to disable AdBlock Plus

1)Click on the icon in the browser’s toolbar.
2)Click on the toggle to disable it for "mrexcel.com".
Go back

Disable uBlock Origin

Follow these easy steps to disable uBlock Origin

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back

Disable uBlock

Follow these easy steps to disable uBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back
Back
Top