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

Create a chart in one keystroke
Select the data and press Alt+F1 to insert a default chart. You can change the default chart to any chart type
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
 
Upvote 0

Forum statistics

Threads
1,214,649
Messages
6,120,732
Members
448,987
Latest member
marion_davis

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