Trying to open a spreadsheet that's read only through macro's.

slay0r

Board Regular
Joined
Jul 8, 2011
Messages
231
Hi Guys,

I'm trying to get a macro to open a spreadsheet and copy the data across, All I'm literally trying to do is open it but unfortunately it's a spreadsheet that's constantly updated by one of our systems.

Because the spreadsheet is obviously read only as a result the macro gets this far and just sticks there. Is there a command to bypass this or a way around? Or even that it opens it in read only, I only want it to copy some data across for me!

Thanks for the help
Jonathan
 

Excel Facts

Why does 9 mean SUM in SUBTOTAL?
It is because Sum is the 9th alphabetically in Average, Count, CountA, Max, Min, Product, StDev.S, StDev.P, Sum, VAR.S, VAR.P.
Sub openstoplist()
'
' openstoplist Macro
' Macro recorded 11/07/2011 by jmartin
'
'
ChDir "S:\ACCOUNTS\Reports\CreditStop"
Workbooks.Open Filename:= _
"S:\ACCOUNTS\Reports\CreditStop\Credit-Stop List.xls"
Windows("copytestmacromaster.xls").Activate
End Sub

Where would I add the readonly bit to that? I'm an absolute noobie at this macro stuff!
 
Upvote 0
Anybody? I'm still a bit lost as I said I don't normally do this kind of thing and I've got nothing to reference to on it. I'm in customer services so I can't really get help from anyone on this!
 
Upvote 0
Try changing
Code:
Workbooks.Open Filename:= _
"S:\ACCOUNTS\Reports\CreditStop\Credit-Stop List.xls"
to
Code:
Workbooks.Open ("S:\ACCOUNTS\Reports\CreditStop\Credit-Stop List.xls", ReadOnly)
as described in the previous post.
Hope that helps,
Cindy
 
Upvote 0
Thank you very much Cindy, as I said complete noobie with this so I didn't know about the brackets etc. Thanks for the help, just noticed 999 posts, 1 more to go use it wisely!
 
Upvote 0
In fact that doesn't seem to be working:

Sub openstoplist20()
'
' openstoplist Macro
' Macro recorded 11/07/2011 by jmartin
'
'
ChDir "S:\ACCOUNTS\Reports\CreditStop"
Workbooks.Open ("S:\ACCOUNTS\Reports\CreditStop\Credit-Stop List.xls",ReadOnly)
Windows("copytestmacromaster.xls").Activate
End Sub

Is there anything else I need to change? It just comes up with Syntax error when I try and execute it.
 
Upvote 0
I typed before thinking...this has been tested (although with my own filenames). It goes back to something closer to the structure you had to start with:
Code:
Sub openstoplist()
'
' openstoplist Macro
' Macro recorded 11/07/2011 by jmartin
'
'
ChDir "S:\ACCOUNTS\Reports\CreditStop"
Workbooks.Open Filename:= _
"S:\ACCOUNTS\Reports\CreditStop\Credit-Stop List.xls" , Readonly:= True
Windows("copytestmacromaster.xls").Activate
End Sub
Hope that helps (and sorry about the misdirection before),
Cindy
 
Upvote 0
Thank you very, very much Cindy, that has worked brilliantly! Hopefully I'll get some praise to pass on when this project of mine is done!
 
Upvote 0

Forum statistics

Threads
1,224,564
Messages
6,179,547
Members
452,925
Latest member
duyvmex

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