Hide/show tabs based on username when shared via OneDrive in web browser

thefork

New Member
Joined
Sep 30, 2022
Messages
2
Office Version
  1. 365
Platform
  1. Windows
  2. Web
Good evening all.

I have gone through various guides to create a workbook that will show certain tabs depending on the users windows username. This works fine but the issue I have is that I then went to share this via OneDrive to colleagues but it doesn't seem to work the same when opening via OneDrive. The current solution is to open it and then choose to open in the desktop app which then works correctly. I assume the UserNameWindows is different in OneDrive but no matter what I try it doesn't seem to work. Does anyone have any suggestions or does OneDrive not allow this functionality?

I have used the below code and have a page on the workbook with usernames and their access levels to link it to.

Function UserNameWindows() As String ‘called from code in Auto_open, below.
UserNameWindows = Environ("UserName")
End Function
 

Excel Facts

Wildcard in VLOOKUP
Use =VLOOKUP("Apple*" to find apple, Apple, or applesauce
OneDrive is just cloud storage. Do you mean UserNameWindows function doesn't work when you open it with Excel Online, but it does when you open it with the desktop version of Excel? If so, what you describe is what I expect would happen. VBA code does not work online - it only works on the desktop. MS have been looking to provide users with online scripting (which is currently called OfficeJS, I think) but I don't know much about it, or if it can do what you're hoping it can it in VBA, but perhaps someone else will.
 
Upvote 0
OneDrive is just cloud storage. Do you mean UserNameWindows function doesn't work when you open it with Excel Online, but it does when you open it with the desktop version of Excel? If so, what you describe is what I expect would happen. VBA code does not work online - it only works on the desktop. MS have been looking to provide users with online scripting (which is currently called OfficeJS, I think) but I don't know much about it, or if it can do what you're hoping it can it in VBA, but perhaps someone else will.
Yep - sorry. Probably could have made the question clearer but you've answered the question. The VBA won't work on office online so that covers that. I'll look at OfficeJS. Thanks.
 
Upvote 0

Forum statistics

Threads
1,214,553
Messages
6,120,176
Members
448,948
Latest member
spamiki

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