LinkBack Thread Tools Search this Thread Display Modes
Prev Previous Post   Next Post Next
  #1   Report Post  
Posted to microsoft.public.excel.programming
URW URW is offline
external usenet poster
 
Posts: 13
Default How to detect locked linked xls file ?

Hi guys,
I am back with another strange one, this time about file locks.
Here is the situation: I have an Excel file (let's call it Parent) that
contains one sheet (among many) that updates some of its data by linking to
another Excel file (let's call it Child). The Parent file is set to
automatically update the fields that are linked to the Child whenever the
Parent is opened.

Now the problem: Sometimes people loose their network connection while
looking at the child file and the child file is locked. It is then impossible
to open the child file until someone reboots the server to release the lock
on the child file. When the child file has been locked like that, opening the
parent brings up a prompt that allows you to retry the child file or cancel
opening it. You click cancel, because retrying won't help until the server
has been rebooted, and get another prompt which you also cancel out off and
finally you can look at the parent file contents.
The parent file is opened by my update process that runs at night unattended
and when that first prompt comes up, it just sits there and waits until I
notice it the next morning and cancel out of the prompt and the process
continues until it comes across another corrupted child file. I need to find
a way to detect that corrupted child file.

I have tried opening either of files in the code to see if I get an error,
but I dont.
The error number is 0 after I try opening the file using this line of code:

Open FullFileName For Binary Access Read Write Lock Read Write As #f

But when open the workbook like this:

Set xb = xa.Workbooks.Open(fileName, True)

I get 2 prompts if FileName is set to the Parent file and 1 prompt if
FileName is set to the Child file name. All the prompts come from Excel I
think, not the file system.


I am new to VBA, as you know and new to Excel and Office Programming, so I
am in the dark here. The call to Open above tells me if the file is open
already by setting Error.Number to 1, but it does not set Error.Number if the
file can not be opened because of the screwed up lock. I tried running

Open "ChildFileName" For Binary Access Read Write Lock Read Write As #f

And Error.Number is 0 after that code runs but if I call

Set xb = xa.Workbooks.Open("ChildFileName", True)

I can not open the workbook and get that prompt.

Do you know of any way to test for a corrupted file that a work book is
linked too? Or maybe there is a way to detect in code that a workbook has put
up a prompt after it was opened and respond to the prompt?

TIA
 
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
Linked spreadsheets failing to recognised that the linked file is Michael Excel Discussion (Misc queries) 0 January 14th 10 12:03 PM
How to automatically make excel detect directory path for linked f rushdhih Excel Discussion (Misc queries) 2 February 20th 09 10:41 AM
Displaying linked data in excel 2007 when linked file is not avail Eng_19 Excel Discussion (Misc queries) 0 December 7th 07 07:27 PM
Please help to detect this file OverAC[_21_] Excel Programming 4 May 12th 06 10:06 AM
In a linked calculation how do I lose the '0' in the linked file? Anita Excel Worksheet Functions 2 February 3rd 06 01:54 PM


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

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

About Us

"It's about Microsoft Excel"