K
kedarkulkarni
Hi,
I have created an excel addin which adds a toolbar after help menu bar.
It opens querydatabase.xls in the same directory where addin exists in
readonly mode and allows you to add, edit, save records.
The file is not shared and saved with a open and readonly password
every time it saves. due to the password nobody opens the file in their
excel window and the addin is used by 15+ staff at a time.
whenever a user wants to add a record or edit record he is given a
userform to add record/ edit record. (the file is opened in the
background in readonly mode and window is hidden to retrieve the
original record to edit the record)
when the usr presses save, the file is opened in exclusive mode and
changes are saved by going to correct row by seeking the correct record
in edit by match function on primary key and if new record then the
last row by xlup
the problem is if 2 staff press save at the same time then excel
sometimes create a file with hex name like A00H080 without extension
(doesnt goto err handler if fails to save with exact name). i dont know
why this happens and how can i make sure that the record is saved or
not.
the line for opening in the background is as follows
workbooks(querydb).open querydbfullpath ,,:true (readonly),readPWD
when saving
workbooks.open querydbfullpath ,,opnPWD,readPWD
if workbooks(querydb).readonly)
msgbox "file is locked by somebody cant save now try after 10
seconds" : exitsub........
endif
change or add a record
workbooks(querydb).saveas workbooks(querydb).fullpath
,,opnPWD,readPWD,exclusive... etc.
workbooks.open querydbfullpath, readonly
but it doesnt return any err msg if the file is not saved. (document
not saved)
I have made sure that the file opened is not in readonly mode after it
is opened with workbooks(querydb).readonly flag.
So if a file is opened in exclusive mode and there is plenty of place
on server and saved immediately why the record isn't saved sometime?
it was working intially ok when file size was below 400k but now gives
a bit problem.
I have created an excel addin which adds a toolbar after help menu bar.
It opens querydatabase.xls in the same directory where addin exists in
readonly mode and allows you to add, edit, save records.
The file is not shared and saved with a open and readonly password
every time it saves. due to the password nobody opens the file in their
excel window and the addin is used by 15+ staff at a time.
whenever a user wants to add a record or edit record he is given a
userform to add record/ edit record. (the file is opened in the
background in readonly mode and window is hidden to retrieve the
original record to edit the record)
when the usr presses save, the file is opened in exclusive mode and
changes are saved by going to correct row by seeking the correct record
in edit by match function on primary key and if new record then the
last row by xlup
the problem is if 2 staff press save at the same time then excel
sometimes create a file with hex name like A00H080 without extension
(doesnt goto err handler if fails to save with exact name). i dont know
why this happens and how can i make sure that the record is saved or
not.
the line for opening in the background is as follows
workbooks(querydb).open querydbfullpath ,,:true (readonly),readPWD
when saving
workbooks.open querydbfullpath ,,opnPWD,readPWD
if workbooks(querydb).readonly)
msgbox "file is locked by somebody cant save now try after 10
seconds" : exitsub........
endif
change or add a record
workbooks(querydb).saveas workbooks(querydb).fullpath
,,opnPWD,readPWD,exclusive... etc.
workbooks.open querydbfullpath, readonly
but it doesnt return any err msg if the file is not saved. (document
not saved)
I have made sure that the file opened is not in readonly mode after it
is opened with workbooks(querydb).readonly flag.
So if a file is opened in exclusive mode and there is plenty of place
on server and saved immediately why the record isn't saved sometime?
it was working intially ok when file size was below 400k but now gives
a bit problem.