[svn.haxx.se] · SVN Dev · SVN Users · SVN Org · TSVN Dev · TSVN Users · Subclipse Dev · Subclipse Users · this month's index

Re: Access violation, when using TortoiseProc.exe to lock a file.

From: Konstantin Kolinko <knst.kolinko_at_gmail.com>
Date: Tue, 20 Jan 2009 18:13:54 +0300

2009/1/20 jerik <jerikmail_at_googlemail.com>:
> Hi,
> OS: Windows
> i wanted to make life easier and create a macro in word, which makes
> it possible to lock the word file which is currently open. The macro
> in word, calls:
> c:\path\TortoiseProc.exe /command:lock /path:"c:\path\file.doc"
> Full macro code:
> Sub svn_lock()
> ' In the Environment varibale svn_cmd is the path to
> TortoiseProc.exe stored!
> svn_cmd = Environ$("svn_cmd")
> svn_cmd_lock = svn_cmd & " /command:lock /path:" & Chr(34) &
> ActiveDocument.FullName & Chr(34)
> Call Shell(svn_cmd_lock)
> End Sub
> I receive the following error message (translated from german):
> An access violation has occured during the access of C:\path\file.doc
> What should I do to avoid the Error message and get the macro to
> work?
> If I use the same macro with the /command:log, it works perfectly. I
> think I have to free the document in a special way, but dont know
> how.
> btw: vba skills novice.
> Cheers -- Jerik

You cannot lock a file that is currently open. The reason is that
Subversion needs to change attributes of the file (remove the
read-only attribute), but it cannot access the file, because it is
already open by MS Word.

Thus the "Cannot access" message.

I think that this problem can be solved by closing and reopening the
document. I mean that the macro should do the following:

1. Get the path of the active document
2. Close the document
3. Run the lock command
4. Open the document

Also, the path to TortoiseProc can be read from the registry (look at
HKLM\Software\TortoiseSVN). Do not know about 64-bit versions, though.

Best regards,
Konstantin Kolinko


To unsubscribe from this discussion, e-mail: [users-unsubscribe_at_tortoisesvn.tigris.org].
Received on 2009-01-20 16:14:09 CET

This is an archived mail posted to the TortoiseSVN Users mailing list.