Original Excel File gets deleted and temp file gets created.

S

Sandy

Guys,

I have a major problem with an Excel workbook that i created and have
been try to resolve this issue for a couple of weeks and my Bosses are
breathing down my neck.

Here is how it works:
I have multiple users using the excel workbook at the same time (they
will open as read only). Once they are done with the data entry they
run a macro. Which will copy data from this excel workbook opens
another file, which is saved in the Shared Drive (Network Drive) and
pastes it as the last entry made in that workbook. If another user is
using this file then it throws an error boxing saying that, "The file
is locked by another user for editing and try after 10 seconds". Then
saves the workbook that it opened from the shared drive and closes it.

The problem is that the macro is running ok till the point of opening
the file making the entry but then when it tried to save the file it
creates a temp file in the same location instead and deletes the
original file. So when other users run the macro again the file does
not get located and they get Run Time error 1004.

This problem is only happening 5 to 10% of the times and usually occurs
when multiple users are trying to save the file at the same time.

I did read the previous threads, the suggestions i got from there were:
It could be an Anti Virus issue. Norton is not scanning this folder.
The users have Read, Write as well as Delete access to this particular
folder.

All help will be greatly appreciated.

Thanks and Regards,
Sandy
 
T

Tom Ogilvy

Think Mark didn't understand the question. The code he sent you to is
worthless for the situation you describe.


http://support.microsoft.com?kbid=138621
XL: Macro Code to Check Whether a File Is Already Open

http://support.microsoft.com?kbid=291295
XL2002: Macro Code to Check Whether a File Is Already Open

http://support.microsoft.com?kbid=213383
XL2000: Macro Code to Check Whether a File Is Already Open

http://support.microsoft.com?kbid=184982
WD97: VBA Function to Check If File or Document Is Open

Will be more along what you want to do as I understand the situation.
 
M

Mark Ivey

Your absolutely right Tom...

I noticed the same thing after I had sent it. I actually sent the wrong
weblink. I had been referencing several before sending that post and
inserted the wrong link.

Thank you for supplying this information.
 
S

Sandy

Hey,

Thank you so much Mark and Tom for your help me thus far.

But I am still facing the same problem

This is the code that I am using:

Sub Test_DB2()
If
IsFileOpen("\\6.193.246.215\Border\Database\CEWAccessDB2MervynsMexico.xls")
Then
MsgBox "The Database File is currently locked for Editing by
another user."
Range("A1").Select
End
Else
Application.Run ("Export_Data_Completed")
End If
End Sub

Function IsFileOpen(filename As String)
Dim filenum As Integer, errnum As Integer
On Error Resume Next
filenum = FreeFile()
Open filename For Input Lock Read As #filenum
Close filenum
errnum = Err
On Error GoTo 0
Select Case errnum
Case 0
IsFileOpen = False
Case 70
IsFileOpen = True
Case Else
Error errnum
End Select
End Function


Sub Export_Data_Completed()
Sheets("Decision").Select
Sheets("Database").Select
Range("Export_Database").Select
Selection.Copy
Workbooks.Open
filename:="\\6.193.246.215\Border\Database\CEWAccessDB2MervynsMexico.xls"
Range("A1").Select
Selection.End(xlDown).Select
Selection.PasteSpecial Paste:=xlValues, Operation:=xlNone, SkipBlanks:=
_
False, Transpose:=False
Application.CutCopyMode = True
ActiveWorkbook.Save
ActiveWorkbook.Close
Sheets("Welcome").Select
End Sub
 
G

Guest

Sandy,

I have been looking over your macro...

A few questions...
1. What is the name of the workbook you want to tranfer data from?
2. What is the worksheet(s) name(s) you wish to transfer data from?
3. What is the path and worksheet name you wish to transfer data to?
4. Are there named ranges associated with any of this data?

If you can answer these questions, I will give it a go to see if I can help
you out.

Mark Ivey
 
M

Mark Ivey

Sandy...

It might be even better if you can email me a copy of the files you are
working with.

(e-mail address removed)
Mark Ivey
 
S

Sandy

hey Mark,

Sent you an email. Please do let me know what you think.

Thank you for helping out.

Regards,
Sandy
 
M

Mark Ivey

Sandy,

I think the problem is more of your network address convention. I tried it
out using my local drives and one network drive that I have mapped in with a
letter and had absolutely no problems. You might do well to re-ask your
question (with code) about the proper method to address the network drive
you are using. I have limited experience in that area, and it might take me
much longer to get you fixed up than the others that are always part of this
newsgroup.

Mark Ivey
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top