FileOpBegin (NotesSession - LotusScript)

Exports a file from the browser virtual file system to the host machine filesystem, or prepares a file system mapping for a new file.

Defined in

NotesSession

Syntax

notesSession.FileOpBegin(filePath$, fileExists)

Parameters

filePath$

String. The path to the file in the browser filesystem

fileExists

Boolean. Whether or not the file exists. If False and the file exists, or True and the file is missing, this method throws an error.

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. FileOpEnd must be called later if the file updates should be saved to the browser file system.

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

Example

This Script extracts an embedded file and moves it to the real filesystem, to then be opened by Microsoft Excel.
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