method open of object workbooks failed

dpaton05

Well-known Member
Joined
Aug 14, 2018
Messages
2,392
Office Version
  1. 365
  2. 2016
Platform
  1. Windows
While working on a spreadsheet at work, I was getting the error "method open of object workbooks failed", but when I got home, the same file was not giving me any errors. Any ideas why?
 

Excel Facts

What is the last column in Excel?
Excel columns run from A to Z, AA to AZ, AAA to XFD. The last column is XFD.
I closed the file without saving it and opened it again as I have not done anything on it today. It is not saying subscript out of range anymore, it is now saying the error is method open of object workbooks failed. It highlights the same line of code.

Workbooks.Open (ThisWorkbook.Path & "" & DocYearName)
 
Upvote 0
Ok try either

Code:
Workbooks.Open (ThisWorkbook.Path & " " & DocYearName)

OR

Code:
Workbooks.Open (ThisWorkbook.Path & "\" & DocYearName)

When you use your error code
Code:
Workbooks.Open (ThisWorkbook.Path & "" & DocYearName)
what do you get ??
I mean what text appears for each variable ?
 
Last edited:
Upvote 0
Dave

Kind of curious, what's the purpose of the If here?
Code:
If Workbooks(ThisWorkbook.Path & "" & DocYearName).Open = True Then

PS If you move the workbook(s) to local storage, e.g. into a folder on the C:\ drive of the computer/laptop, do you have any problems opening workbooks?
 
Upvote 0
I'm sorry, the line of code that I am using should or read
Code:
Workbooks.Open Filename:=ThisWorkbook.Path & "\" & DocYearName

I made a typo in post 12
 
Last edited:
Upvote 0
If I use
Code:
Workbooks.Open (ThisWorkbook.Path & "" & DocYearName)
I get an error saying the file can't be found.

If I use
Code:
Workbooks.Open (ThisWorkbook.Path & "" & DocYearName)
I get the same error.
 
Upvote 0
Dave

Kind of curious, what's the purpose of the If here?

I read on a forum that a possible fix is to make sure the workbook is closed before you copy to it. It didn't work for me so I just commented it out.
 
Upvote 0
Both lines of code look the same to me !!
Did you take Nories advice of moving the file to say the C:\ Drive??
 
Last edited:
Upvote 0
PS If you move the workbook(s) to local storage, e.g. into a folder on the C:\ drive of the computer/laptop, do you have any problems opening workbooks?

I get the same error. Do you think that the workbook may have been corrupted as I read somewhere that could be a possible cause for the error?
 
Upvote 0
Can you open the workbook manually either by double clicking the file or opening it from within Excel?
 
Upvote 0

Forum statistics

Threads
1,224,823
Messages
6,181,180
Members
453,021
Latest member
Justyna P

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