method open of object workbooks failed

dpaton05

Well-known Member
Joined
Aug 14, 2018
Messages
2,352
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?
 
Do you mean that I should not copy anything? I have a lot of previous versions. Do you think I could try an earlier version first?
 
Upvote 0

Excel Facts

Select a hidden cell
Somehide hide payroll data in column G? Press F5. Type G1. Enter. Look in formula bar while you arrow down through G.
Why not simply make a copy of the latest version, and use that ??
AND
Now might be a good time for a cleanout !!!...you have about 8 modules that could be removed.
quite a few macros that could be placed in one module, and a heap of code in Sheet modules that should be in Standard modules......:cool:
 
Last edited:
Upvote 0
Do you mean that I should not copy anything? I have a lot of previous versions. Do you think I could try an earlier version first?

You can copy the information, select the first sheet, select all the cells and copies, in the new book on the first sheet, in cell A1 you paste.


And so you do it sheet by sheet.


Something in your book was damaged, that's why you should only recover the data, not the complete sheets.
 
Upvote 0
It is really strange that the file works on my home pc but won't work on the computer I use at work.
 
Upvote 0
It also seems odd that we can make it work at different sites.........BUT......you are working with 2 different versions of Excel !!!
 
Upvote 0
Sorry Dante, I went to work today but thought that my problem was with the quoting tool, not the allocation sheets, so I never thought of trying the new allocation sheet you sent me. I will try that new file you sent me when I am next at work, so Friday. Thanks guys for helping me with this issue.
 
Upvote 0
Got another problem.

I have this code to delete a selected row but if you delete all the rows, it deletes the formulas at the end of the table. These formulas are required to make it work. I need code to not delete the formulas if it has only one row left. Here is the code that I have:

Code:
Private Sub cmdDelSelectRow_Click()

ActiveSheet.Unprotect Password:="npssadmin"
    Dim rng As Range
    
    On Error Resume Next
    With Selection.Cells(1)
        Set rng = Intersect(.EntireRow, ActiveCell.ListObject.DataBodyRange)
        On Error GoTo 0
        If rng Is Nothing Then
            MsgBox "Please select a cell within a row that you want to delete.", vbCritical
        Else
            rng.Delete xlShiftUp
        End If
    End With
    
'ListObjects("NPSS_quote").ListColumns("10%Increase").DataBodyRange.Value = "1"

Application.EnableEvents = True
'ActiveSheet.Protect Password:="npssadmin"
End Sub


I am still getting random errors. By that I mean, sometimes I will get errors and sometimes I won't. Should I convert the allocation sheets (where the rows are being copied too), to be a table in each sheet as the conversion works pretty well to go from the quoting tool to the costing tool, and they are both tables?
 
Upvote 0
One of the errors is sub script out of range. This is the highlighted line of code:
Code:
 Set wsDst = Workbooks(DocYearName).Worksheets(Combo)

If I hover over it, DocYearName is "2018 - 2019 NPSS Work Allocation Sheet.xlsm" and if I hover over over Combo I get the July, but both files are stored in the same folder.
 
Last edited:
Upvote 0
Try something like this
AND
with regard to converting to tables, I reckon in your case, tables have been a causing a lot of the problems !
Personally, I wouldn't have used them for the processes involved in your workbook.....but that's a personal choice on my part...:biggrin:
Code:
Private Sub cmdDelSelectRow_Click()

ActiveSheet.Unprotect Password:="npssadmin"
    Dim rng As Range
    
    On Error Resume Next
    With Selection.Cells(1)
        Set rng = Intersect(.EntireRow, ActiveCell.ListObject.DataBodyRange)
        On Error GoTo 0
        If rng Is Nothing Then
            MsgBox "Please select a cell within a row that you want to delete.", vbCritical
        Else
         [color=red]If rng.HasFormula = False Then rng.Delete[/color]
        End If
    End With
    
'ListObjects("NPSS_quote").ListColumns("10%Increase").DataBodyRange.Value = "1"

Application.EnableEvents = True
'ActiveSheet.Protect Password:="npssadmin"
End Sub
 
Upvote 0

Forum statistics

Threads
1,215,510
Messages
6,125,241
Members
449,217
Latest member
Trystel

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