Open file macro failing

MOB

Well-known Member
Joined
Oct 18, 2005
Messages
1,055
Office Version
  1. 365
Platform
  1. Windows
I have this code, which is automatically run each day on our server - works fine, until sometimes it fails as the file appears to be already in use by "admin" and I assume therefore the macro doesn't know to press "read only" :)

The file being opened read only doesn't cause any issues.


Sub Open8050()

ChDir "Y:\Data Files\Sales"
Workbooks.Open Filename:="Y:\Data Files\Sales\8050 Report.xlsx"

ChDir "Y:\Data Files\Flash"
Workbooks.Open Filename:="Y:\Data Files\Flash\Flash Data.xlsx", UpdateLinks _
:=0
ActiveWorkbook.Save
ActiveWindow.Close

Workbooks("8050 Report.xlsx").Close

End Sub


Any pointers on the best way to handle this would be great - the spreadsheets simply open, update, and I run a further macro that creates a table and saves the file somewhere else.

My code probably isn't the greatest but it works apart from this issue :)

TIA
 

Excel Facts

Easy bullets in Excel
If you have a numeric keypad, press Alt+7 on numeric keypad to type a bullet in Excel.

Forum statistics

Threads
1,215,084
Messages
6,123,029
Members
449,092
Latest member
ikke

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