Simple Code stops working when workbook opened Read Only

Pete_Bristol

Board Regular
Joined
Mar 8, 2006
Messages
122
Dear All,

Please can you help with a simple(?) problem I am having.

The following code works perfectly on a workbook that has been opened exclusively by one person. Essentially, the user has clicked a hyperlink on a summary page and the macro unhides and selects the relevant sheet.

However, when the workbook is opened by another person as read-only (i.e the first person is still in it), this macro (and infact lots of others, all with select statements in them) fails with the message "select method worksheet class failed" and then "unable to set the visible property".

Code:
Private Sub Workbook_SheetFollowHyperlink(ByVal Sh As Object, ByVal Target As Hyperlink)
Dim sName As String
sName = Left(Target.SubAddress, (InStr(1, Target.SubAddress, "!") - 1))
Worksheets(sName).Visible = True
Worksheets(sName).Select
End Sub

I am sure I have done this millions of times before without problem. Why wont it allow me to select the sheet when the workbook is readonly? Incidentally, the spreadsheet is simply a reporting spreadsheet no input is actually made in it.

Please can you advise what I am missing or why it wont work.

Many thanks,

Pete
 

Excel Facts

Copy a format multiple times
Select a formatted range. Double-click the Format Painter (left side of Home tab). You can paste formatting multiple times. Esc to stop

Seanzies

Board Regular
Joined
Nov 19, 2005
Messages
212
Looks like it's related to the Worksheets(sName).Visible = True line.
Becuase your in ReadOnly you aren't able to make any changes to the sheets, ie make a sheet visible.

I don't know of any way around this
 
Master Excel Bundle

Excel contains over 450 functions, with more added every year. That’s a huge number, so where should you start? Right here with this bundle.

Forum statistics

Threads
1,164,675
Messages
5,838,718
Members
430,566
Latest member
ChanchalSingh

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
Top