PC Review


Reply
Thread Tools Rate Thread

Disable share workbook option in VBA

 
 
Les Allan
Guest
Posts: n/a
 
      29th Mar 2010
I've got a workbook with a lot of code and want to prevent users from
sharing the workbook. If they share the workbook, it only generates
error messages for them and creates problems.

If I could hide the command bar option or catch when they go to share
the workbook and cancel the action, that would be great. But I
searched high and low on how to do this with no luck. Users will be
using XL 2002 up to 2007. Does anyone have any ideas or faced this
challenge before?

Les
 
Reply With Quote
 
 
 
 
john
Guest
Posts: n/a
 
      29th Mar 2010
Les,
you can disable a commandbar menu item

Sub Disable_ShareWorkbook_MenuItem()
'xl2003
Application.CommandBars("Worksheet Menu Bar").FindControl _
(ID:=2040, Recursive:=True).Enabled = False

End Sub

can't help you with 2007 version.


--
jb


"Les Allan" wrote:

> I've got a workbook with a lot of code and want to prevent users from
> sharing the workbook. If they share the workbook, it only generates
> error messages for them and creates problems.
>
> If I could hide the command bar option or catch when they go to share
> the workbook and cancel the action, that would be great. But I
> searched high and low on how to do this with no luck. Users will be
> using XL 2002 up to 2007. Does anyone have any ideas or faced this
> challenge before?
>
> Les
> .
>

 
Reply With Quote
 
Les Allan
Guest
Posts: n/a
 
      29th Mar 2010
Thanks John,

That works like a charm in XL 2003. It would be a treat if I can also
stop XL 2007 users from sharing the workbook. I thought of capturing
the user clicking on the share workbook option in the
Workbook_BeforeSave procedure with something like:

With ThisWorkbook
If .MultiUserEditing Then
<code that cancels sharing>
End If
End With

But this only triggers once the workbook is already saved. Has anyone
else tried to prevent w/b sharing in XL 2007? Or what do other people
do with users that try to share a w/b that will lead to errors if
shared?

Les
 
Reply With Quote
 
 
 
Reply

Thread Tools
Rate This Thread
Rate This Thread:

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
Share option not there? =?Utf-8?B?QnJpYW4gUHJlc3Rvbg==?= Microsoft Outlook Calendar 1 22nd Nov 2007 12:02 AM
Disable print option of a worksheet/workbook =?Utf-8?B?TmVsbHkwNw==?= Microsoft Excel Misc 0 23rd Oct 2007 10:19 PM
Share Workbook option grayed out =?Utf-8?B?V2llY3pLaWQ=?= Microsoft Excel Discussion 2 3rd May 2007 09:19 PM
How can I share and un-share a workbook using a macro? =?Utf-8?B?Qm90dGVy?= Microsoft Excel Programming 2 4th Oct 2006 06:39 PM
Can't share workbook. The "Share Workbook" option is off. Why? =?Utf-8?B?RG95bGUgRGllbmVy?= Microsoft Excel Misc 4 24th Apr 2006 06:56 PM


Features
 

Advertising
 

Newsgroups
 


All times are GMT +1. The time now is 08:19 PM.