Forum Discussion

GeorgieAnne's avatar
GeorgieAnne
Iron Contributor
Mar 26, 2025
Solved

Open and Repair Workbook

Hello Excellers,

Is there any harm in using Open and Repair on a workbook that is not malfunctioning, just to makes sure that there are no issued?

 

Any VBA example on how to invoke the Open and Repair option on a workbook.

 

Thanks in advance.

GiGi!

  • No, it won't hurt, but it will always report that errors were detected and repaired, even if there were none.

    You can specify that the workbook should be repaired when you open it:

    Sub Test()
        Dim wbk As Workbook
        Set wbk = Workbooks.Open(Filename:="Book1.xlsx", CorruptLoad:=xlRepairFile)
    End Sub

    When you run this, the same message will pop up that you see when you select Open and Repair manually.

    If you want to suppress this:

    Sub Test()
        Dim wbk As Workbook
        Application.DisplayAlerts = False
        Set wbk = Workbooks.Open(Filename:="Book1.xlsx", CorruptLoad:=xlRepairFile)
        Application.DisplayAlerts = True
    End Sub

     

2 Replies

  • No, it won't hurt, but it will always report that errors were detected and repaired, even if there were none.

    You can specify that the workbook should be repaired when you open it:

    Sub Test()
        Dim wbk As Workbook
        Set wbk = Workbooks.Open(Filename:="Book1.xlsx", CorruptLoad:=xlRepairFile)
    End Sub

    When you run this, the same message will pop up that you see when you select Open and Repair manually.

    If you want to suppress this:

    Sub Test()
        Dim wbk As Workbook
        Application.DisplayAlerts = False
        Set wbk = Workbooks.Open(Filename:="Book1.xlsx", CorruptLoad:=xlRepairFile)
        Application.DisplayAlerts = True
    End Sub

     

    • GeorgieAnne's avatar
      GeorgieAnne
      Iron Contributor

      Thank You HansVogelaar 

      Yes these messages should be suppressed so that if the user goes to say get a cup of coffee, the code can continue and not waste all that time until the user comes back.

      GiGi