Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.misc
external usenet poster
 
Posts: 22
Default Problem removing sharing from workbook via Macro

I have hundreds of Excel files that are currently set as "shared" but I want
to remove this feature.

I tried to create code to do this by recording the action of me unsharing
one workbook.

This produces the code:

ThisWorkbook.ExclusiveAccess

I then added Application.DisplayAlerts = False before the line above and
Application.DisplayAlerts = True after the line above to produce the
following. I did this because there is a message box that pops up when you
unshare in Excel warning about various things. I wanted to skip this.


Application.DisplayAlerts = False
ThisWorkbook.ExclusiveAccess
Application.DisplayAlerts = True

When I run this I get an error though. The error is:

Run-Time error '1004':
Method 'ExclusiveAccess' of object '_Workbook' failed

End/Debug/Help etc....

Can anyone suggest why I am getting this error message or how I can alter my
code to unshare a workbook without getting an error?

Many thanks!

  #2   Report Post  
Posted to microsoft.public.excel.misc
external usenet poster
 
Posts: 22,906
Default Problem removing sharing from workbook via Macro

This works for me.

Sub foo()
Application.DisplayAlerts = False

If ActiveWorkbook.MultiUserEditing Then
ActiveWorkbook.ExclusiveAccess
End If

Application.DisplayAlerts = True
End Sub


Gord Dibben MS Excel MVP

On Thu, 25 Oct 2007 11:32:29 -0700, BenS wrote:

I have hundreds of Excel files that are currently set as "shared" but I want
to remove this feature.

I tried to create code to do this by recording the action of me unsharing
one workbook.

This produces the code:

ThisWorkbook.ExclusiveAccess

I then added Application.DisplayAlerts = False before the line above and
Application.DisplayAlerts = True after the line above to produce the
following. I did this because there is a message box that pops up when you
unshare in Excel warning about various things. I wanted to skip this.


Application.DisplayAlerts = False
ThisWorkbook.ExclusiveAccess
Application.DisplayAlerts = True

When I run this I get an error though. The error is:

Run-Time error '1004':
Method 'ExclusiveAccess' of object '_Workbook' failed

End/Debug/Help etc....

Can anyone suggest why I am getting this error message or how I can alter my
code to unshare a workbook without getting an error?

Many thanks!


  #3   Report Post  
Posted to microsoft.public.excel.misc
external usenet poster
 
Posts: 22
Default Problem removing sharing from workbook via Macro

Gord,

Thank you so much. Your code worked perfectly and ended my frustration over
this problem. Thanks for all the time this is going to save me!

-Ben

"Gord Dibben" wrote:

This works for me.

Sub foo()
Application.DisplayAlerts = False

If ActiveWorkbook.MultiUserEditing Then
ActiveWorkbook.ExclusiveAccess
End If

Application.DisplayAlerts = True
End Sub


Gord Dibben MS Excel MVP

On Thu, 25 Oct 2007 11:32:29 -0700, BenS wrote:

I have hundreds of Excel files that are currently set as "shared" but I want
to remove this feature.

I tried to create code to do this by recording the action of me unsharing
one workbook.

This produces the code:

ThisWorkbook.ExclusiveAccess

I then added Application.DisplayAlerts = False before the line above and
Application.DisplayAlerts = True after the line above to produce the
following. I did this because there is a message box that pops up when you
unshare in Excel warning about various things. I wanted to skip this.


Application.DisplayAlerts = False
ThisWorkbook.ExclusiveAccess
Application.DisplayAlerts = True

When I run this I get an error though. The error is:

Run-Time error '1004':
Method 'ExclusiveAccess' of object '_Workbook' failed

End/Debug/Help etc....

Can anyone suggest why I am getting this error message or how I can alter my
code to unshare a workbook without getting an error?

Many thanks!



  #4   Report Post  
Posted to microsoft.public.excel.misc
external usenet poster
 
Posts: 22,906
Default Problem removing sharing from workbook via Macro

Glad to help.

Now all you have to do is get it to loop through the "hundreds" of workbooks.


Gord

On Thu, 25 Oct 2007 15:17:00 -0700, BenS wrote:

Gord,

Thank you so much. Your code worked perfectly and ended my frustration over
this problem. Thanks for all the time this is going to save me!

-Ben

"Gord Dibben" wrote:

This works for me.

Sub foo()
Application.DisplayAlerts = False

If ActiveWorkbook.MultiUserEditing Then
ActiveWorkbook.ExclusiveAccess
End If

Application.DisplayAlerts = True
End Sub


Gord Dibben MS Excel MVP

On Thu, 25 Oct 2007 11:32:29 -0700, BenS wrote:

I have hundreds of Excel files that are currently set as "shared" but I want
to remove this feature.

I tried to create code to do this by recording the action of me unsharing
one workbook.

This produces the code:

ThisWorkbook.ExclusiveAccess

I then added Application.DisplayAlerts = False before the line above and
Application.DisplayAlerts = True after the line above to produce the
following. I did this because there is a message box that pops up when you
unshare in Excel warning about various things. I wanted to skip this.


Application.DisplayAlerts = False
ThisWorkbook.ExclusiveAccess
Application.DisplayAlerts = True

When I run this I get an error though. The error is:

Run-Time error '1004':
Method 'ExclusiveAccess' of object '_Workbook' failed

End/Debug/Help etc....

Can anyone suggest why I am getting this error message or how I can alter my
code to unshare a workbook without getting an error?

Many thanks!




Reply
Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules

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


Similar Threads
Thread Thread Starter Forum Replies Last Post
removing a macro from a workbook Roger Excel Worksheet Functions 2 December 22nd 06 08:30 PM
How do I resolve a problem with sharing a workbook Carter Excel Worksheet Functions 0 August 15th 06 09:45 PM
Problem Sharing Workbook Nospam Excel Discussion (Misc queries) 0 April 4th 06 09:31 PM
Problem removing hyperlinks in workbook Tai-Pan Excel Discussion (Misc queries) 5 October 21st 05 11:32 PM
Problem executing a macro from different workbook where it is Sergio Calleja Excel Discussion (Misc queries) 1 January 17th 05 12:38 PM


All times are GMT +1. The time now is 07:44 AM.

Powered by vBulletin® Copyright ©2000 - 2024, Jelsoft Enterprises Ltd.
Copyright ©2004-2024 ExcelBanter.
The comments are property of their posters.
 

About Us

"It's about Microsoft Excel"