Open file macro failing

MOB

Well-known Member
Joined
Oct 18, 2005
Messages
1,066
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

What does custom number format of ;;; mean?
Three semi-colons will hide the value in the cell. Although most people use white font instead.

Forum statistics

Threads
1,223,911
Messages
6,175,324
Members
452,635
Latest member
laura12345

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