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

Wildcard in VLOOKUP
Use =VLOOKUP("Apple*" to find apple, Apple, or applesauce

NdNoviceHlp

Well-known Member
Joined
Nov 9, 2002
Messages
2,660
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,118,192
Messages
5,570,771
Members
412,340
Latest member
nikitesh95
Top