ブラウザの仮想ファイルシステムからホストマシンのファイルシステムにファイルをエクスポートするか、新しいファイルのファイルシステムマッピングを準備します。
NotesSession
notesSession.FileOpBegin(filePath$, fileExists)
filePath$
String 値。ブラウザのファイルシステム内のファイルへのパス。
fileExists
Boolean 値。ファイルが存在するかどうか。False でファイルが存在する場合、もしくは、True でファイルが存在しない場合は、このメソッドはエラーを返します。
このメソッドは、COM アプリケーションが LotusScriptで Notes 内に含まれるファイルにアクセスする必要があるとき、COM を呼び出すために Nomad Web で使用されます。
ブラウザの仮想ファイルシステムにファイルがある場合(NotesEmbeddedObject.extractfile 経由で取得したファイルなど)、FileOpBegin はファイルをマシンの物理ドライブ上の一時的な場所にエクスポートします。 このファイルは、仮想ファイルを COM コマンドに渡す際に自動的に使用されます。
ファイルの更新をブラウザファイルシステムに保存する必要がある場合は、後で FileOpEnd を呼び出す必要があります。
注記: 非 Web クライアントでは、この関数はエラーが発生します。
このスクリプトは埋め込まれたファイルを抽出し、実際のファイルシステムに移動して、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