FileOpEnd (NotesSession - LotusScript)

Completes a file operation started by FileOpBegin. The host machine file is copied back into the browser virtual file system at the location specified in FileOpBegin, and deleted from the host file system.

Syntax

notesSession.FileOpBegin(filePath$)

Parameters

filePath$

String. The path to the file in the browser filesystem.

Usage

This method is used in Nomad Web when calling COM from LotusScript where the COM application will need access to a file contained within Notes.

When you have a file in the browser virtual file system(like a file obtained via NotesEmbeddedObject.extractfile), FileOpBegin will export the file to a temporary location on your machine's physical drive, and this file will automatically be used when you pass the virtual file to COM commands. Calling FileOpEnd will copy the file from the temporary location back to the browser file system.

Note: On non-web clients, this function will throw an error.

Example

This Script creates a new file with COM and attaches it to a database.
Sub Click(Source As Button)
	Dim session As NotesSession
	Dim db As NotesDatabase
	Dim view As NotesView
	Dim doc As NotesDocument
	Dim obj As NotesEmbeddedObject
	Dim rt As NotesRichTextItem
	Dim excel As Variant
	Dim sheetpath As String
	Dim webBrowser As Boolean
	Dim ws As New NotesUIWorkspace
	Set session = New NotesSession
	If session.Platform = "WebBrowser" Then	
		webBrowser = True
	Else
		webBrowser = False
	End If
	Set db = session.CurrentDatabase
	Set view = db.GetView("Files")
	Set doc = view.GetFirstDocument
	If webBrowser Then
		sheetpath = "vfs:/tmp/testsheet.xlsx"
	Else
		sheetpath = "c:\tmp\testsheet.xlsx"
	End If
	Set rt = doc.getFirstItem("FileAttachment")
	Set obj = rt.embeddedObjects(0)
	Call obj.extractfile(sheetpath)
	If webBrowser Then
		session.FileOpBegin sheetpath, True
	End If
	Set excel = CreateObject("Excel.Application")
	excel.Visible = True
	excel.Workbooks.Open(sheetpath)
	saveit = ws.Prompt(Prompt_YESNO, "", "replace attachment?")	
	If saveit  = 1 Then
		If webBrowser Then
			session.FileOpEnd(sheetpath) 
		End If
		obj.Remove
		Call rt.EmbedObject(EMBED_ATTACHMENT, "", sheetpath)
		Call doc.Save(True, False)
	End If
End Sub