ind = 0 for each doc in me.Documents If doc.DefinitionName = "" and doc.Index > 0 then For each page in doc.Pages me.MovePage doc,me.Documents.Item(ind),page.index,me.Documents.Item(ind).Pages.Count next else ind = doc.Index End if next if me.Documents.Item(0).DefinitionName = "" then If me.Properties.Has("ExportPath") then FilePath=me.Properties.Get("ExportPath") Set FSO = CreateObject("Scripting.FileSystemObject") if not FSO.FolderExists(FilePath) then FSO.CreateFolder FilePath fctools.ShowMessage "создана папка " & FilePath end if set fso = nothing end if FileName = "BatchId_" & me.Documents.Item(0).Batch.Id & "DocId_" & Documents.Item(0).Id & "_" & FormatDateTime(Me.CreationDate, 2) set imageOptions = FCTools.NewImageSavingOptions imageOptions.Format = "pdf" imageOptions.ColorType = "GrayScale" imageOptions.ShouldOverwrite=true imageOptions.UseMRC=false Set xmlDoc = CreateObject("Microsoft.XMLDOM") Set Doc = xmlDoc.createElement("_Doc") xmlDoc.appendChild Doc Set Barcode = xmlDoc.createElement("Barcode1") Barcode.Text="" Doc.appendChild Barcode Set Barcode = nothing Set FilePathName = xmlDoc.createElement("_FilePathName") FilePathName.Text = me.Documents.Item(0).Pages.Item(0).ImageSource Doc.appendChild FilePathName Set FilePathName = nothing town = "" region = "" Set FolderName = xmlDoc.createElement("FolderName") str = me.Documents.Item(0).Pages.Item(0).ImageSource If InStrRev(str, "\") > 0 Then str = Mid(str, InStrRev(str, "\")+1) x1 = InStr(str, "_") If x1 > 0 Then region = Mid(str, 1, x1 - 1) x2 = InStr(x1+1, str, "_") If x2 > 0 Then str = Mid(str, x1 + 1, x2 - x1 - 1) town = str End If End If End If FolderName.Text=str Doc.appendChild FolderName Set FolderName = nothing Set Intro = xmlDoc.createProcessingInstruction ("xml","version='1.0'") xmlDoc.insertBefore Intro,xmlDoc.childNodes(0) FileName = "DocId_" & Documents.Item(0).Id & "_" & FormatDateTime(Me.CreationDate, 2) If town <> "" Then FileName = town & "_" & Documents.Item(0).Id xmlDoc.Save FilePath & "\" & FileName & ".xml" me.Documents.Item(0).SaveAs FilePath & "\" & FileName & ".pdf", imageOptions end if