Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 27
Default How to forcely remove or overwrite an open excel file

Hi,

We gather data form various excel files accross our network and combine
them. However, we can't proceed if a user left a file open as it generates an
error. We can't ignore such file so is there any way to get the file copied
to a different location then close the original and replace it with a copy?
Every time we try to do this we get Access denied error if the file is open.

Your help would be highly appreciated.

Peter
  #2   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 2,203
Default How to forcely remove or overwrite an open excel file

Are you opening the other workbooks from code or manually in Excel?

If you're opening them in VBA code, you can open them in Read Only mode and
later Close them without saving changes. But if you need to clear out data
that you've copied from them, then you still have the same problem - trying
to take control of an open file that someone else owns. If that's truly a
show stopping situation, then user education may be the only answer.

Here are examples of the .Open and .Close commands in VBA that could help you.

Application.DisplayAlerts = False
'open the workbook without updating links and in read only mode
Workbooks.Open "X:\DailyLog\pathto.xls", False, True
Application.DisplayAlerts = True

and to close without saving any perceived changes
Application.DisplayAlerts = False
Workbooks("pathto.xls").Close False
Application.DisplayAlerts = True


"Piotr (Peter)" wrote:

Hi,

We gather data form various excel files accross our network and combine
them. However, we can't proceed if a user left a file open as it generates an
error. We can't ignore such file so is there any way to get the file copied
to a different location then close the original and replace it with a copy?
Every time we try to do this we get Access denied error if the file is open.

Your help would be highly appreciated.

Peter

  #3   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 27
Default How to forcely remove or overwrite an open excel file

Thanks a lot for this information. So we just need to forcus on education
then...

Regards,
Peter

"JLatham" wrote:

Are you opening the other workbooks from code or manually in Excel?

If you're opening them in VBA code, you can open them in Read Only mode and
later Close them without saving changes. But if you need to clear out data
that you've copied from them, then you still have the same problem - trying
to take control of an open file that someone else owns. If that's truly a
show stopping situation, then user education may be the only answer.

Here are examples of the .Open and .Close commands in VBA that could help you.

Application.DisplayAlerts = False
'open the workbook without updating links and in read only mode
Workbooks.Open "X:\DailyLog\pathto.xls", False, True
Application.DisplayAlerts = True

and to close without saving any perceived changes
Application.DisplayAlerts = False
Workbooks("pathto.xls").Close False
Application.DisplayAlerts = True


"Piotr (Peter)" wrote:

Hi,

We gather data form various excel files accross our network and combine
them. However, we can't proceed if a user left a file open as it generates an
error. We can't ignore such file so is there any way to get the file copied
to a different location then close the original and replace it with a copy?
Every time we try to do this we get Access denied error if the file is open.

Your help would be highly appreciated.

Peter

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
Remove Prompt to Open File as Read-Only (Excel 2007) kerryb13 Excel Discussion (Misc queries) 3 April 19th 23 02:13 PM
Overwrite Open Excel files on Macro instereo911 Excel Programming 0 April 14th 09 07:12 PM
open text file in Excel and remove columns SLP Excel Discussion (Misc queries) 5 August 14th 08 04:37 PM
Remove Macros before send? & Runtime error if choosing not to overwrite file? nbaj2k[_30_] Excel Programming 17 August 11th 06 11:42 AM
Calc status of open excel workbook should not overwrite another Michael Hill Setting up and Configuration of Excel 1 October 28th 05 06:48 PM


All times are GMT +1. The time now is 01:49 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"