'Unable to read file' error

picklefactory

Well-known Member
Joined
Jan 28, 2005
Messages
506
Office Version
  1. 365
Platform
  1. Windows
Hi folks.
I've started to get this error with one specific wb that we've been running for over 12 months trouble free. Online search has come up with numerous possible reasons for this, but none that seem to fit my circumstances, just wondering if anyone here may have some further knowledge? I'm not sure if it's more a Microsoft issue than Excel, but the fact that it only seems to affect one wb makes me wonder if there's something in that one contributing to the issue.
Also, I've run the wb on 4 different machines, 3 running Office 2016 all see the error, the one machine running Office 365 is error free, the wb is on a shared network, so it's the same wb being run by all.
OK, what the wb does is opens an .xls sheet via VBA, which is an exported .xls from our SAP system, it then opens a 2nd .xls which is purely a flowery display version of the final output data to run in a scrolling .ppt in the main office (The ppt kept glitching with the .xlsm, and would only work with an xls). It just juggles and re-formats the data from the SAP export file and then transfers it to the display xls in a nice, visual format. It also, based on the contents, sends a reminder email out to selected people that there are outstanding issues within the data.
So nothing particularly clever, and has worked perfectly for over 12 months.
I should emphasise though, that I get the 'Unable to read file' error every time, but when I hit the OK button on the error, the wb then carries on and completes all it's functions without further issue.
I'm wondering if there might be a compatibility issue within my code maybe, between the Office versions? Windows and Office seem to update almost weekly, so I'm also wondering if a recent update may have had some effect.
All code enclosed. I have a basic module just setting print area and the major stuff is all in an 'On workbook open' UDF
Any suggestions I could try please?

Code:
Sub setprintarea()

Dim myrange As String

myrange = Range("R2").Value

ActiveSheet.PageSetup.PrintArea = "$A$1:J" & myrange

End Sub


Code:
Private Sub Workbook_BeforeClose(Cancel As Boolean)
    
    ActiveSheet.Unprotect ""
    
    If ActiveSheet.FilterMode Then
    ActiveSheet.ShowAllData
    End If
    
    ActiveSheet.Protect "", AllowFiltering:=True
    
End Sub

Private Sub Workbook_Open()
    
    Application.ScreenUpdating = False
    
    ActiveSheet.Unprotect ""
    
Set wb = Application.Workbooks.Open("M:\COMPANY SHARED\POWERPOINT NOTICE BOARD\LASER BEND ORDERS.xls")
Set wb1 = Application.Workbooks.Open("M:\COMPANY SHARED\POWERPOINT NOTICE BOARD\OUTSTANDING ORDERS DISPLAY.xls")

Workbooks("CHASE OUTSTANDING ORDERS.xlsm").Activate

    Workbooks("CHASE OUTSTANDING ORDERS.xlsm").Worksheets("Sheet1").Range("A2:J30").Copy
    Workbooks("OUTSTANDING ORDERS DISPLAY.xls").Worksheets("Sheet1").Range("A2:J30").PasteSpecial Paste:=xlPasteValues


wb.Close
wb1.Close savechanges:=True

    
'GoTo Skip

Dim result As String
If (WorksheetFunction.CountIf(Range("'Sheet1'!I2:'Sheet1'!I20"), "Yes")) = 0 Then
    Exit Sub
    Else:
    
Dim OutApp As Object
 Dim OutMail As Object
 Set OutApp = CreateObject("Outlook.Application")
 Set OutMail = OutApp.CreateItem(0)

With OutMail
.To = "user1@email.co.uk;"
.CC = "user2@email.co.uk;"
.Subject = "ITEMS ARE OVERDUE ON FABRICATION ORDER SCHEDULE"
.Body = "PLEASE CHECK PROGRESS SHEET FOR DETAILS M:\COMPANY SHARED\POWERPOINT NOTICE BOARD\CHASE OUTSTANDING ORDERS.xlsm"
.NoAging = True
.Display
End With
Set OutMail = Nothing
Set OutApp = Nothing
SendKeys "{NUMLOCK}%{s}", True

End If


Skip:

ActiveSheet.Protect ""
Application.ScreenUpdating = True

End Sub
 
Just tried another option which is just as frustrating.
Based on my supposition above, I tried disabling auto update of links in the Excel options for this workbook only, and adding some code to update links AFTER the two source wb's have opened. I cannot get that to save. I uncheck the option, save the wb, re-open and it's back on again.

Code added highlighted in red

Code:
Private Sub Workbook_Open()
    Application.ScreenUpdating = False
    
    ActiveSheet.Unprotect ""
    
    
Set wb = Application.Workbooks.Open("M:\COMPANY SHARED\POWERPOINT NOTICE BOARD\LASER BEND ORDERS.xls")
Set wb1 = Application.Workbooks.Open("M:\COMPANY SHARED\POWERPOINT NOTICE BOARD\OUTSTANDING ORDERS DISPLAY.xls")

[COLOR="#FF0000"]Application.DisplayAlerts = False
ActiveWorkbook.UpdateLink Name:=ActiveWorkbook.LinkSources, Type:=xlExcelLinks[/COLOR]

Workbooks("CHASE OUTSTANDING ORDERS.xlsm").Activate


    Workbooks("CHASE OUTSTANDING ORDERS.xlsm").Worksheets("Sheet1").Range("A2:J30").Copy
    Workbooks("OUTSTANDING ORDERS DISPLAY.xls").Worksheets("Sheet1").Range("A2:J30").PasteSpecial Paste:=xlPasteValues


wb.Close
wb1.Close savechanges:=True

    
GoTo Skip

Dim result As String
If (WorksheetFunction.CountIf(Range("'Sheet1'!I2:'Sheet1'!I20"), "Yes")) = 0 Then
    Exit Sub
    Else:
    
Dim OutApp As Object
 Dim OutMail As Object
 Set OutApp = CreateObject("Outlook.Application")
 Set OutMail = OutApp.CreateItem(0)

With OutMail
.To = "sfenlon@phoenixtavinor.co.uk;"
.CC = "terryf@phoenixtavinor.co.uk;"
.Subject = "ITEMS ARE OVERDUE ON FABRICATION ORDER SCHEDULE"
.Body = "PLEASE CHECK PROGRESS SHEET FOR DETAILS M:\COMPANY SHARED\POWERPOINT NOTICE BOARD\CHASE OUTSTANDING ORDERS.xlsm"
.NoAging = True
.Display
End With
Set OutMail = Nothing
Set OutApp = Nothing
SendKeys "{NUMLOCK}%{s}", True

End If


Skip:

ActiveSheet.Protect ""
Application.ScreenUpdating = True


End Sub

Now, where's my big hammer?????
 
Last edited:
Upvote 0

Excel Facts

What is the fastest way to copy a formula?
If A2:A50000 contain data. Enter a formula in B2. Select B2. Double-click the Fill Handle and Excel will shoot the formula down to B50000.

Forum statistics

Threads
1,214,932
Messages
6,122,334
Members
449,077
Latest member
Jocksteriom

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