Hi,I am stuck with this problem, can anybody help me?
I am trying to edit attachments using LotusScript.
If the attachment name does not contain any space, my script works fine. But if the file name has space in between the words, such as ‘employee names.doc’, I get the error message saying that the file name is invalid … In the error message box, the attachment name was displayed as ‘c:\ Department\employee’ instead of ‘c:\Department\employee names.doc’.
In my script 3 public subs are called.
The 1st one detaches and opens the file for users to update.
The 2nd one removes the attachment from the rich text field.
The 3rd one attaches the file back to the rich text field.
The execution stops at ‘ShellAndWait ( Cstr ( ExeFile ) & FullPath$ )’ in the 1st sub.
Here is the 1st sub:
Public Sub DetachAndEdit (AttName As String , InItem As String )
'// Detach a file from the current document and edit the file in the associated application
TempPath$ = Left ( WorkDir , ( Len ( WorkDir ) - 1 ) )
dummy& = DetachByName ( InItem , AttName , TempPath$ , 1 )
LastModificationTime = FileLastModified ( AttName )
FullPath$ = TempPath$ & "" & AttName
ExeFile = FindExecutableByExtension ( FullPath$ ) & " " '// Find the executable for the
detached file
ShellAndWait ( Cstr ( ExeFile ) & FullPath$ ) '// Launch the file with the associated
application
End Sub
Private Sub ShellAndWait(Byval RunProg As String)
Dim proc As PROCESS_INFORMATION
Dim StartInf As STARTUPINFO
StartInf.cb = Len(StartInf)
RetVal = CreateProcessA(0&, RunProg, 0&, 0&, 1&,
NORMAL_PRIORITY_CLASS, 0&, 0&, StartInf, proc)
RetVal = WaitForSingleObject(proc.hProcess, INFINITE)
RetVal = CloseHandle(proc.hProcess)
End Sub