Solution 1 – Use GetOpenFilename Method
To solve the problem of “method open of object workbooks failed”, you need to use VBA. Microsoft Visual Basic for Applications (VBA) is Microsoft’s Event Driven Programming Language. To use this feature you first need to have the Developer tab showing on your ribbon. Click here to see how you can show the Developer tab on your ribbon.
Steps:
- VBA has its own separate window to work with. You have to insert the code in this window. To open the VBA window, go to the Developer tab on your ribbon. Select Visual Basic from the Code
- VBA modules hold the code in the Visual Basic Editor. It has a .bcf file extension. We can create or edit one through the VBA editor window. To insert a module for the code, go to the Insert tab on the VBA editor. Click on Module from the drop-down.
- A new module will be created.
- Select the module.Enter the following code.
Sub Opening_Workbook ()
Dim strrFile As String
strrFile = Application.GetOpenFilename()
Workbooks.Open (strrFile)
End Sub
- Save the code.
- Click on Run.
- A Open window will appear.
- Choose the workbook which you want to open.
- Click OK.
Read More: VBA Object Variable or with Block Variable Not Set in Excel
Solution 2 – Apply Correct File Path While Opening Workbook
Steps:
- Go to the Developer tab on your ribbon. Select Visual Basic from the Code group.
- Go to the Insert tab on the VBA editor. Click on Module from the drop-down.
- A new module will be created.
- Select and enter the following code.
Sub Macro_2()
Workbooks.Open Filename:="C:\Users\USER\Desktop\saquib\61-0081\How to Forecast Cash Flow in Excel.xlsx"
End Sub
- Save the code.
- Click on Run.
Note:
Sometimes, when the above code is not working to solve the problem, the Approve-It add-in may be the main issue in some cases. Disable it from your system.
In some cases, the Foxit reader add-in was causing the problem. Remove it.
Read More: [Fixed!] Subscript Out of Range Error in Excel VBA
Solution 3 – Make Sure File Is Not Corrupted
Occasionally, a corrupted file will cause the error “method open of object workbooks failed” when opening a file in read-only mode. As a result, Excel would give an error since it can only fix corrupt files by writing to them and repair files only if they are allowed to be opened. A corrupt file cannot be repaired in read-only mode, so if you try to open it in this mode, it will not open. A corruption occurred because the sources for the dropdown list on another spreadsheet were not copied.
To solve this problem, open the input file manually and resave it and change the function name.
Read More: Reasons And Solutions for Excel Object Required Error in VBA
Solution 4 – Avoid Running Excel on Net.App Application
This problem may occur because of MS Excel running on the Net.App application where VBA wasn’t installed accurately.
- Go to Control Panel and select Program and Features and uninstall this program.
- Find the installed office, right-click and choose Change.
Read More: [Fixed!] Excel Application-Defined or Object-Defined Error in VBA
Download Practice Workbook
Related Articles
- How to Fix Compile Error in Hidden Module in Excel
- [Fixed!] Invalid Forward Reference in VBA
- [Fixed!] Unable to Set the Visible Property of the Worksheet Class
- Because of Your Security Settings Macros Have Been Disabled
- [Solved]: User Defined Type Not Defined in Excel VBA
- Sub or Function Not Defined in Excel VBA
- [Solved!] Excel VBA “Argument Not Optional” Error