|
LITTLEBLACKDOG.COM
|
| Author |
Message |
dstg_ll
-=* NSFW *=-


Joined: 14 Jun 2002 Age: 33 Posts: 14105
Location: Black Pearl
|
Posted:
Tue Mar 24, 2009 10:28 am Post subject: [VBA] OPEN FOR with network file ? |
|
Can't find anything on the net, so i'll try here...
When i use this line of code in VBA (Word 2003) :
fnum = FreeFile()
Open MyFile For Append Shared As fnum
... on a file that's on the network \\somewhere\somefolder\somefile.txt\ , the file is locked when another user tries to write in the same file (with the same macro). I can't delete or write in that file unless i go on the computer that just ran the macro and delete it manually.
How can i unlock the file so everyone can write in it ? Is there a way to do this ? |
|
|
|
|
|
|
anglachel
Guide Dog


Joined: 08 Nov 2003 Posts: 9129
Location: MN
|
Posted:
Tue Mar 24, 2009 12:13 pm Post subject: |
|
do you close the file when your done?
Something like "MyFile.close". |
_________________
Quidquid latine dictum sit, altum sonatur.
Death to Shuttleworth!
|
|
|
|
|
dstg_ll
-=* NSFW *=-


Joined: 14 Jun 2002 Age: 33 Posts: 14105
Location: Black Pearl
|
Posted:
Wed Mar 25, 2009 5:55 am Post subject: |
|
Yes... Close #fnum
Here's the whole code:
Private Sub btnSave_Click()
Dim myDate
Dim myTime
Dim txtNow As String
Dim Msg, Style, Title, Help, Ctxt, Response, MyString
MyFile = "\\Nas1-6ea\CORR\" & "CORRectionsTM_ALL.txt"
myDate = DateValue(Now)
myTime = TimeValue(Now)
txtNow = Format(myDate, "dddd d mmm yyyy") + ", " + Format(myTime, "Hh:Mm:Ss")
'set and open file for output
fnum = FreeFile()
Open MyFile For Append Shared As fnum
Print #fnum, "*************************************************************************"
Print #fnum, "<Demandeur> " + txtDemandeur.Text
Print #fnum, "<Corrigé le> " + txtNow
Print #fnum, "<Corrigé par> " + cbUSER.Text
Print #fnum, ""
Print #fnum, "<Mémoire(s) Corrigée(s)> " + txtMem.Text
Print #fnum, ""
Print #fnum, "<Source> " + txtSource.Text
Print #fnum, "<Erreur> " + txtOld.Text
Print #fnum, "<Correction> " + txtCorr.Text
Print #fnum, "*************************************************************************"
Print #fnum, ""
Print #fnum, ""
Close #fnum
Msg = "Correction sauvegardé dans le fichier: " + MyFile + vbCrLf + vbCrLf + "Voulez-vous entrer une autre correction ?" ' Définit le message.
Style = vbYesNo + vbQuestion + vbDefaultButton2
Title = "Opération Terminé !"
' Affiche le message.
Response = MsgBox(Msg, Style, Title)
If Response = vbNo Then ' L'utilisateur a choisi Non.
End ' Effectue une action.
End If
End Sub |
|
|
|
|
|
|
|
|
|
|
View next topic
View previous topic
You cannot post new topics in this forum You cannot reply to topics in this forum You cannot edit your posts in this forum You cannot delete your posts in this forum You cannot vote in polls in this forum
|
Powered by phpBB
© 2001, 2002 phpBB Group
phpBB SEO
All times are GMT - 8 Hours
Help us keep advertisements off this site. Donate today!
|
|