Vba cannot open file run time error 2147021892 800070bbc

Son

Active Member
Joined
Mar 19, 2010
Messages
284
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
 

Excel Facts

Add Bullets to Range
Select range. Press Ctrl+1. On Number tab, choose Custom. Type Alt+7 then space then @ sign (using 7 on numeric keypad)
Hi Son. U can trial....
Code:
Application.displayalerts = False
Workbooks.Open fName
                ....
ActiveWorkbook.Close False
Application.displayalerts = True
HTH. Dave
 
Upvote 0

Forum statistics

Threads
1,215,461
Messages
6,124,955
Members
449,199
Latest member
Riley Johnson

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