Vba cannot open file run time error 2147021892 800070bbc

Son

Active Member
Joined
Mar 19, 2010
Messages
281
Hi all, I have a vba code that opens xls files and does various things then close the xls file not saving it.

The code used to work fine in excel 2003-2007 but in excel 2016 I receive an error like this "run time error 2147021892 800070bbc".

From what I understand excel 2016 wants to open the xls files in protected view or with a button to enable editing. But how can I bypass this runtime error and open the xls anyway?

I have tried to change setting in the trust center, I have disable almost all controls and still nothing.

The code is very simple and, as I said, used to work fine:
VBA Code:
fName = Dir("*.xls")
    Do While Len(fName) > 0
            If fName <> ThisWorkbook.Name And fName <> "0000.xls" And Len(fName) < 17 Then
                 Workbooks.Open fName
                ....
               ActiveWorkbook.Close False      'make this TRUE of you want to save the changes made to the wb opened
        End If
        fName = Dir         'next file
    Loop

Any ideas or suggestions would be most appreciated!!!
Son
 

Some videos you may like

Excel Facts

When did Power Query debut in Excel?
Although it was an add-in in Excel 2010 & Excel 2013, Power Query became a part of Excel in 2016, in Data, Get & Transform Data.

NdNoviceHlp

Well-known Member
Joined
Nov 9, 2002
Messages
2,723
Hi Son. U can trial....
Code:
Application.displayalerts = False
Workbooks.Open fName
                ....
ActiveWorkbook.Close False
Application.displayalerts = True
HTH. Dave
 

Watch MrExcel Video

Forum statistics

Threads
1,122,450
Messages
5,596,221
Members
414,046
Latest member
mbeutler1203

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
Top