Dim db As NotesDatabase,ws As New notesuiworkspace,s As New NotesSession,itm As NotesRichTextItem
Set db = s.currentdatabase
Set uidoc = ws.CurrentDocument
Call uidoc.save
Set doc = uidoc.Document
Call doc.replaceitemvalue("tema","Постановление")
Call doc.Save( True , False )
Set itm = doc.GetFirstItem("Body")
' Set WShell = CreateObject("WScript.Shell")
Set view = db.GetView ( "($TEMPLATES)" )
Set TemplateDoc = view.GetDocumentByKey ( "Постановление" )
Set TemplateField = TemplateDoc.GetFirstItem ( "Body" )
If ( TemplateField.Type = RICHTEXT ) Then
Forall o In TemplateField.EmbeddedObjects
Call o.ExtractFile ( "c:\lotustemp\" & o.Name )
TName = o.Name
End Forall
End If
file = "c:\lotustemp\" & TName
'ReturnCode = WShell.Run("swriter.exe " + file,1)
Dim mass()
Dim xlWbk As Variant
Set xlglob = CreateObject ( "com.sun.star.ServiceManager" )
Set Desktop = xlglob.createInstance("com.sun.star.frame.Desktop")
Set document= Desktop.loadComponentFromURL("file:///"+file, "_blank", 0, mass)
' Print "Файл " + TName + " сохранен как " + file
'*********************** проверка на использование файла его редактируемой программой
Dim OriginalFileDateTime As Variant
OriginalFileDateTime = Filedatetime(file)
Print "дата исходного файла " + Cstr(Filedatetime(file))
Dim Flag As Boolean
Flag = True
While Flag
Sleep(0.5)
Flag = IsFileOpen(file)
'ждём пока OpenOffice не освободит файл
Wend
'о! освободил
Print "дата сохраненного файла " + Cstr(Filedatetime(file))
If Filedatetime(file) <> OriginalFileDateTime Then
'Файл сохранили и закрыли - процесь
Call itm.embedObject(EMBED_ATTACHMENT,"", file)
End If
Function IsFileOpen(fileName) As Integer
Dim filenum As Integer
fileNum = Freefile()
On Error 101 Goto errorFileAlreadyOpen
Open fileName For Input Access Read Write As filenum ' менял эту строчку по всякому, открывает вайл только на чтение и все
Close filenum
IsFileOpen = False
Exit Function
errorFileAlreadyOpen:
IsFileOpen = True
Exit Function
End Function