IDocumentReplaceFile Method |
There are three different scenarios:
The document record exists but filename is empty. The file is saved and the document record is updated with files name
The document record exists but not the file. File is saved with name from document record.
The document record and file exists. If the content of the files differs the existing content is
Namespace: SuperOffice.COM.SuperOfficeDB
ReplaceFile
This text may be copied to the notepad, and saved as a *.vbs file. Remember to change the login information. You also need two different files, with different text to verify. The examples use c:\test.doc and c:\test2.doc
Dim objDB, objApp, soDoc Set objDB = CreateObject("SuperOfficeDB.Database") Set objApp = CreateObject("SuperOffice.Application") objDB.Login objApp.Database.Username, objApp.Database.Password Set soDoc = objDB.CreateDocument soDoc.SetDefaults soDoc.Contact = objDB.GetContact(2) soDoc.Header = "Added though SuperCOM" soDoc.Save objApp.database.Refresh objApp.SetContext 2, 0, 0 MsgBox "Check for the added document with header Added through SuperCOM, try to open." & vbCrLf & "It fails since we have not yet created a document file." soDoc.ReplaceFile "c:\test.doc", False soDoc.Save objApp.database.Refresh MsgBox "Now try to open the file" soDoc.ReplaceFile "c:\test2.doc", False soDoc.Save objApp.database.Refresh MsgBox "Now try to open the file, verify that the text is replaced."