Vba share workbook

yoko

Active Member
Joined
Sep 5, 2006
Messages
349
Can vba be used to make a workbook shared? If so how?

Cheers,
 

Excel Facts

How to total the visible cells?
From the first blank cell below a filtered data set, press Alt+=. Instead of SUM, you will get SUBTOTAL(9,)
Err because it’s not unwanted. I sill need an answer and 'bumped' it up the forum to make it more visible.
 
Upvote 0
Hi

The only way I can think to share macros is to have a seperate workbook which contains all your coding that everyone opens in read only mode, with vb references made to the shared book, if that makes sense?

It does mean that 2 workbooks are open, but maybe you you can put a note in the shared workbook for each user to open the "vba" workbook.

Hope it helps
 
Upvote 0
Yoko,

I've found a way to do what I think you want.

To share a workbook using vba use this code:

Code:
ActiveWorkbook.SaveAs FileName, , , , , , xlShared

Where 'FileName' is the path and name of your file. The file MUST be saved in order to enable sharing.

To unshare the workbook use this code:

Code:
If ActiveWorkbook.MultiUserEditing Then
    ActiveWorkbook.ExclusiveAccess
End If

I would recommend saving the file as well immediately after changing it from Shared to unshared:


Code:
ActiveWorkbook.SaveAs FileName

Hope this works for you.

Take Care.

Owen
 
Upvote 0
Hi,
i have one small question.

how can you use the code for unsharing after you shared the workbook, as when the workbook is share you can no longer access the macros?



Yoko,

I've found a way to do what I think you want.

To share a workbook using vba use this code:

Code:
ActiveWorkbook.SaveAs FileName, , , , , , xlShared

Where 'FileName' is the path and name of your file. The file MUST be saved in order to enable sharing.

To unshare the workbook use this code:

Code:
If ActiveWorkbook.MultiUserEditing Then
    ActiveWorkbook.ExclusiveAccess
End If

I would recommend saving the file as well immediately after changing it from Shared to unshared:


Code:
ActiveWorkbook.SaveAs FileName

Hope this works for you.

Take Care.

Owen
 
Upvote 0

Forum statistics

Threads
1,223,911
Messages
6,175,322
Members
452,635
Latest member
laura12345

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