Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
Bob Bob is offline
external usenet poster
 
Posts: 972
Default Getting unexpected error message

Near the end of my procedure (which is located in PERSONAL.XLS) , I have the
following lines of code:

Application.DisplayAlerts = False
ActiveWorkbook.ProtectSharing SharingPassword:="password"
ActiveWorkbooks.Close SaveChanges:=False
Application.DisplayAlerts = True

(Please note that my procedure starts out by opening a workbook located on a
network shared drive.)

When Excel executes the 3rd line of code above, my procedure stops and I get
the following error message:

Run-time error.
This workbook contains macros recorded or written in Visual Basic.
Macros cannot be viewed or edited in shared workbooks.

Given that Application.DisplayAlerts has been set to False, I don't
understand why the error message is appearing.

Does anyone have any ideas on how I can modify the lines above to prevent
the error message from appearing? Thanks.

  #2   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 6,953
Default Getting unexpected error message

If you don't save changes, what is the point of making a change in the status
of the workbook.

All messages are not suppressed by Application.DisplayAlerts

--
Regards,
Tom Ogilvy




"Bob" wrote:

Near the end of my procedure (which is located in PERSONAL.XLS) , I have the
following lines of code:

Application.DisplayAlerts = False
ActiveWorkbook.ProtectSharing SharingPassword:="password"
ActiveWorkbooks.Close SaveChanges:=False
Application.DisplayAlerts = True

(Please note that my procedure starts out by opening a workbook located on a
network shared drive.)

When Excel executes the 3rd line of code above, my procedure stops and I get
the following error message:

Run-time error.
This workbook contains macros recorded or written in Visual Basic.
Macros cannot be viewed or edited in shared workbooks.

Given that Application.DisplayAlerts has been set to False, I don't
understand why the error message is appearing.

Does anyone have any ideas on how I can modify the lines above to prevent
the error message from appearing? Thanks.

  #3   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 3,986
Default Getting unexpected error message

If the workbook was password protected when it was opened, and you did
nothing to remove that protection, why would you need to add the protection a
second time, especially when you don't want to save the modifications at that
point anyhow? Or am I reading this code wrong.

"Bob" wrote:

Near the end of my procedure (which is located in PERSONAL.XLS) , I have the
following lines of code:

Application.DisplayAlerts = False
ActiveWorkbook.ProtectSharing SharingPassword:="password"
ActiveWorkbooks.Close SaveChanges:=False
Application.DisplayAlerts = True

(Please note that my procedure starts out by opening a workbook located on a
network shared drive.)

When Excel executes the 3rd line of code above, my procedure stops and I get
the following error message:

Run-time error.
This workbook contains macros recorded or written in Visual Basic.
Macros cannot be viewed or edited in shared workbooks.

Given that Application.DisplayAlerts has been set to False, I don't
understand why the error message is appearing.

Does anyone have any ideas on how I can modify the lines above to prevent
the error message from appearing? Thanks.

  #4   Report Post  
Posted to microsoft.public.excel.programming
Bob Bob is offline
external usenet poster
 
Posts: 972
Default Getting unexpected error message

Tom / JLGWhiz,

Prior to the lines of code I showed below, my procedure opens the workbook
and unshares it. I then modify some data within the workbook and then
re-save it.

The lines of code show below are the lines that are excuted after I have
re-saved the workbook. I need to re-share the workbook (similar to if I
clicked on Tools, Protection, Protect and Share Workbook...). When the 3rd
line of code below is executed, Excel does indeed re-share the workbook.
Afterwards, however, execution stops when I then try to Close the workbook.

Does this additional info help?

Thanks again for any assistance.
Bob


"Bob" wrote:

Near the end of my procedure (which is located in PERSONAL.XLS) , I have the
following lines of code:

Application.DisplayAlerts = False
ActiveWorkbook.ProtectSharing SharingPassword:="password"
ActiveWorkbooks.Close SaveChanges:=False
Application.DisplayAlerts = True

(Please note that my procedure starts out by opening a workbook located on a
network shared drive.)

When Excel executes the 3rd line of code above, my procedure stops and I get
the following error message:

Run-time error.
This workbook contains macros recorded or written in Visual Basic.
Macros cannot be viewed or edited in shared workbooks.

Given that Application.DisplayAlerts has been set to False, I don't
understand why the error message is appearing.

Does anyone have any ideas on how I can modify the lines above to prevent
the error message from appearing? Thanks.

  #5   Report Post  
Posted to microsoft.public.excel.programming
Bob Bob is offline
external usenet poster
 
Posts: 972
Default Getting unexpected error message

Sorry, I meant to say, "When the 2nd line of code below is executed..."


"Bob" wrote:

Tom / JLGWhiz,

Prior to the lines of code I showed below, my procedure opens the workbook
and unshares it. I then modify some data within the workbook and then
re-save it.

The lines of code show below are the lines that are excuted after I have
re-saved the workbook. I need to re-share the workbook (similar to if I
clicked on Tools, Protection, Protect and Share Workbook...). When the 3rd
line of code below is executed, Excel does indeed re-share the workbook.
Afterwards, however, execution stops when I then try to Close the workbook.

Does this additional info help?

Thanks again for any assistance.
Bob


"Bob" wrote:

Near the end of my procedure (which is located in PERSONAL.XLS) , I have the
following lines of code:

Application.DisplayAlerts = False
ActiveWorkbook.ProtectSharing SharingPassword:="password"
ActiveWorkbooks.Close SaveChanges:=False
Application.DisplayAlerts = True

(Please note that my procedure starts out by opening a workbook located on a
network shared drive.)

When Excel executes the 3rd line of code above, my procedure stops and I get
the following error message:

Run-time error.
This workbook contains macros recorded or written in Visual Basic.
Macros cannot be viewed or edited in shared workbooks.

Given that Application.DisplayAlerts has been set to False, I don't
understand why the error message is appearing.

Does anyone have any ideas on how I can modify the lines above to prevent
the error message from appearing? Thanks.



  #6   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 6,953
Default Getting unexpected error message

So you are saying the workbook is sitting opened shared.

I don't know how you will retain that setting unless you save the workbook.
Maybe Excel does something sneaky and updates the file to show it is save
without saving the workbook, but I wouldn't think so.

Nonetheless, I can't say why you are getting an error.

--
Regards,
Tom Ogilvy



"Bob" wrote:

Sorry, I meant to say, "When the 2nd line of code below is executed..."


"Bob" wrote:

Tom / JLGWhiz,

Prior to the lines of code I showed below, my procedure opens the workbook
and unshares it. I then modify some data within the workbook and then
re-save it.

The lines of code show below are the lines that are excuted after I have
re-saved the workbook. I need to re-share the workbook (similar to if I
clicked on Tools, Protection, Protect and Share Workbook...). When the 3rd
line of code below is executed, Excel does indeed re-share the workbook.
Afterwards, however, execution stops when I then try to Close the workbook.

Does this additional info help?

Thanks again for any assistance.
Bob


"Bob" wrote:

Near the end of my procedure (which is located in PERSONAL.XLS) , I have the
following lines of code:

Application.DisplayAlerts = False
ActiveWorkbook.ProtectSharing SharingPassword:="password"
ActiveWorkbooks.Close SaveChanges:=False
Application.DisplayAlerts = True

(Please note that my procedure starts out by opening a workbook located on a
network shared drive.)

When Excel executes the 3rd line of code above, my procedure stops and I get
the following error message:

Run-time error.
This workbook contains macros recorded or written in Visual Basic.
Macros cannot be viewed or edited in shared workbooks.

Given that Application.DisplayAlerts has been set to False, I don't
understand why the error message is appearing.

Does anyone have any ideas on how I can modify the lines above to prevent
the error message from appearing? Thanks.

  #7   Report Post  
Posted to microsoft.public.excel.programming
Bob Bob is offline
external usenet poster
 
Posts: 972
Default Getting unexpected error message

Yes, I first save the workbook, then re-share it (it was in share mode when I
first opened it and then I unshared it), and finally close it. When I
perform these steps manually, everything works fine. But when I try to do it
in VBA, that's when I get the error message. Go figure.

Thanks all the same.
Bob


"Tom Ogilvy" wrote:

So you are saying the workbook is sitting opened shared.

I don't know how you will retain that setting unless you save the workbook.
Maybe Excel does something sneaky and updates the file to show it is save
without saving the workbook, but I wouldn't think so.

Nonetheless, I can't say why you are getting an error.

--
Regards,
Tom Ogilvy



"Bob" wrote:

Sorry, I meant to say, "When the 2nd line of code below is executed..."


"Bob" wrote:

Tom / JLGWhiz,

Prior to the lines of code I showed below, my procedure opens the workbook
and unshares it. I then modify some data within the workbook and then
re-save it.

The lines of code show below are the lines that are excuted after I have
re-saved the workbook. I need to re-share the workbook (similar to if I
clicked on Tools, Protection, Protect and Share Workbook...). When the 3rd
line of code below is executed, Excel does indeed re-share the workbook.
Afterwards, however, execution stops when I then try to Close the workbook.

Does this additional info help?

Thanks again for any assistance.
Bob


"Bob" wrote:

Near the end of my procedure (which is located in PERSONAL.XLS) , I have the
following lines of code:

Application.DisplayAlerts = False
ActiveWorkbook.ProtectSharing SharingPassword:="password"
ActiveWorkbooks.Close SaveChanges:=False
Application.DisplayAlerts = True

(Please note that my procedure starts out by opening a workbook located on a
network shared drive.)

When Excel executes the 3rd line of code above, my procedure stops and I get
the following error message:

Run-time error.
This workbook contains macros recorded or written in Visual Basic.
Macros cannot be viewed or edited in shared workbooks.

Given that Application.DisplayAlerts has been set to False, I don't
understand why the error message is appearing.

Does anyone have any ideas on how I can modify the lines above to prevent
the error message from appearing? 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
Solver Error - an unexpected internal error has occurred Steve Excel Discussion (Misc queries) 1 February 12th 09 03:18 AM
Solver Error - an unexpected internal error has occurred Steve Excel Discussion (Misc queries) 0 February 12th 09 02:19 AM
Unexpected message when first opening this 2007 Excel file Jugglertwo Excel Discussion (Misc queries) 1 November 12th 08 07:31 PM
Autorecover: Unexpected Error message recipients unite... [email protected] Excel Discussion (Misc queries) 0 June 12th 06 02:41 PM
Unexpected error message on closing an Excel file KG Excel Discussion (Misc queries) 1 March 21st 05 02:39 PM


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

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"