Tricky mutiple users problem...

UKPhil

New Member
Joined
Jul 25, 2002
Messages
49
I have written a small excel sheet which acts like a questionaire for employees. Everyone has a copy of this file on their desktop, when they fill out the form and submit it opens a master file and adds that persons details to the list. What I want to do is add a routine which:
before submitting the users details checks if the file is already open
if it is, the results are not sent to the master list but saved as a temporary .xls sheets in the same directory

I can then add a routine to the Auto_open macro to check for temp files and add their contents next time the file is opened, then delete the temporary file from the directory.

Can this be done within a macro? or can anyone think of a better way around this problem?

Thanks-in-advance

UKPhil
 

Excel Facts

Last used cell?
Press Ctrl+End to move to what Excel thinks is the last used cell.
are you using windows NT?

If you are (and this is probably too long winded...) - you could save their file automatically on the basis of their login (Environ.Username), and then have the master file run through pick up all the individual files and add the data before killing the file.
 
Upvote 0
You can use the GetAttr function to check whether a file is already open ie read only.

Extract from help:

GetAttr Function


Returns an Integer representing the attributes of a file, directory, or folder.

Syntax

GetAttr(pathname)

The required pathname argument is a string expression that specifies a file name. The pathname may include the directory or folder, and the drive.

Return Values

The value returned by GetAttr is the sum of the following attribute values:

Constant Value Description
vbNormal 0 Normal.
vbReadOnly 1 Read-only.
vbHidden 2 Hidden.
vbSystem 4 System file. Not available on the Macintosh.
vbDirectory 16 Directory or folder.
vbArchive 32 File has changed since last backup. Not available on the Macintosh.
vbAlias 64 Specified file name is an alias. Available only on the Macintosh.



Note These constants are specified by Visual Basic for Applications. The names can be used anywhere in your code in place of the actual values.

Remarks

To determine which attributes are set, use the And operator to perform a bitwise comparison of the value returned by the GetAttr function and the value of the individual file attribute you want. If the result is not zero, that attribute is set for the named file. For example, the return value of the following And expression is zero if the Archive attribute is not set:

Result = GetAttr(FName) And vbArchive

A nonzero value is returned if the Archive attribute is set.

So in your case:

Code:
Result = GetAttr("YourFileName") And vbReadOnly
If Result = 0 Then
'*** Open the file ***
Else
'*** Copy to temporary workbook ***
End if
 
Upvote 0

Forum statistics

Threads
1,214,430
Messages
6,119,442
Members
448,898
Latest member
drewmorgan128

We've detected that you are using an adblocker.

We have a great community of people providing Excel help here, but the hosting costs are enormous. You can help keep this site running by allowing ads on MrExcel.com.
Allow Ads at MrExcel

Which adblocker are you using?

Disable AdBlock

Follow these easy steps to disable AdBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the icon in the browser’s toolbar.
2)Click on the "Pause on this site" option.
Go back

Disable AdBlock Plus

Follow these easy steps to disable AdBlock Plus

1)Click on the icon in the browser’s toolbar.
2)Click on the toggle to disable it for "mrexcel.com".
Go back

Disable uBlock Origin

Follow these easy steps to disable uBlock Origin

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back

Disable uBlock

Follow these easy steps to disable uBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back
Back
Top