C
Chrisso
Hi All,
I have Word VB code that prepares Word files for distribution to our
users. It does two things:
1. add modules to the Word file (using Application.OrganizerCopy)
2. opens the Word file and adds text to headers and footers.
Sub Prepare_File_For_Distribution(sPath As String, sName As String)
' 1. copy module:
Application.OrganizerCopy _
Source:=ThisDocument.Path & Application.PathSeparator &
ThisDocument.Name, _
Destination:=sPath & sName, _
Name:="Destroy_Date_Adder", _
Object:=wdOrganizerObjectProjectItems
' 2. add text
Documents.Open sPath & sName ' <<< problem here
Add_Uncontrolled_Text Documents(sName)
Documents(sName).Close True
End Sub
I am having trouble in between these two steps.
I am sure I am the only person using the files as I am in test/debug
mode yet Windows insists the file is locked. When I attempt to open
the file I get a Windows pop-up saying "<file> is locked for editing
by 'another user'".
I still get the same message even after testing for the ~$<file>
hidden file which I believe is how the locking is implemented by
Windows. I have written code to test for its existence, remove it,
sleep a second and then try again to open the file but to no avail.
Does anyone have any advice on why I am seeing this problem and how
can I work around it?
Thanks in advance for any ideas - I am quite stuck on this problem.
Chrisso
I have Word VB code that prepares Word files for distribution to our
users. It does two things:
1. add modules to the Word file (using Application.OrganizerCopy)
2. opens the Word file and adds text to headers and footers.
Sub Prepare_File_For_Distribution(sPath As String, sName As String)
' 1. copy module:
Application.OrganizerCopy _
Source:=ThisDocument.Path & Application.PathSeparator &
ThisDocument.Name, _
Destination:=sPath & sName, _
Name:="Destroy_Date_Adder", _
Object:=wdOrganizerObjectProjectItems
' 2. add text
Documents.Open sPath & sName ' <<< problem here
Add_Uncontrolled_Text Documents(sName)
Documents(sName).Close True
End Sub
I am having trouble in between these two steps.
I am sure I am the only person using the files as I am in test/debug
mode yet Windows insists the file is locked. When I attempt to open
the file I get a Windows pop-up saying "<file> is locked for editing
by 'another user'".
I still get the same message even after testing for the ~$<file>
hidden file which I believe is how the locking is implemented by
Windows. I have written code to test for its existence, remove it,
sleep a second and then try again to open the file but to no avail.
Does anyone have any advice on why I am seeing this problem and how
can I work around it?
Thanks in advance for any ideas - I am quite stuck on this problem.
Chrisso