ISLibraryDocument.SaveToFile

Description

This function saves the library document content to the specified file.

Syntax

object.SaveToFile aFileName

Part Attribute Type Description
object Required
The object always implements the ISLibraryDocument interface
aFileName In, Required
string
The name of the destination file

Example

Find the library document by its name and save it to the disk after user confirmation.

sub main
  Dim aDocumentName 
  Dim aLibrary
  
  aDocumentName = InputBox("Enter document name to save:")
  if aDocumentName = "" then exit sub
    
  Set aLibrary = Profile.LoadRootLibrary
  ProcessLibraryTree aLibrary, "", aDocumentName
end sub
     
sub ProcessLibraryTree(aLibrary, aPath, aDocumentName)
  Dim aFullPath
  Dim aDoc
  Dim aInfo
  Dim aResult
  Dim aDialog
  Dim i
    
  if aPath <> "" then        
    aFullPath = aPath & "\" & aLibrary.Name
  else
    aFullPath = aLibrary.Name
  end if
        
  set aDoc = aLibrary.GetDocumentByName(aDocumentName)
  if not aDoc is nothing then
    aInfo = aFullPath & "\" & aDoc.Name
    aResult = MsgBox("Would you like to save document " & vbNewLine & aInfo & " ?",_
      vbYesNo, "Save document")
    if aResult = vbYes then 
      set aDialog = Profile.CreateSaveDialog
      aDialog.Title = "Save " & aInfo    
      aDialog.Filter = "*.txt||*.rtf||*.doc||*.*||"      
      aDialog.FileName = aDoc.Name & "_"  & aDoc.TypeCode  
      if aDialog.Execute then aDoc.SaveToFile(aDialog.FileName)
    end if
  end if 
     
  for i = 0 to aLibrary.Count - 1
    ProcessLibraryTree aLibrary.SubLibrary(i), aFullPath, aDocumentName  
  next
end sub  
Note:

In Profile Client v8 on User Interface the library document can be saved by clicking the 'Save selected document' button in Maintain > Library > Items toolbar.

Version information

Added in v7.9.0