スクリプトからWSHを動かす
ロングファイルネームのファイルを取得するときにスクリプトがエラーになる場合、
スクリプトからWSHを起動することでムリヤリ回避できます。
スクリプトからWSHを起動することでムリヤリ回避できます。
スクリプト例
ある文書にパスと複数のファイル名が設定されているとします。
その複数のファイルを取得し、一度ローカルにコピーしたものを
メール文書に添付してメール送信を行います。
(c:\dataのフォルダはすでに在ると仮定。)
その複数のファイルを取得し、一度ローカルにコピーしたものを
メール文書に添付してメール送信を行います。
(c:\dataのフォルダはすでに在ると仮定。)
Set db = session.CurrentDatabase
Dim wksp As New NotesUIWorkspace
Dim Parent As NotesDocument
Set Parent = wksp.CurrentDocument.Document
Dim wksp As New NotesUIWorkspace
Dim Parent As NotesDocument
Set Parent = wksp.CurrentDocument.Document
'--WSH使用のための宣言
Dim oWSH
Set oWSH = CreateObject("Scripting.FileSystemObject")
Dim newFile As String
Dim oWSH
Set oWSH = CreateObject("Scripting.FileSystemObject")
Dim newFile As String
'--DL対象ファイルのファイル名とファイルパスを取得
Dim DllFileName As Variant
Dim DllFilePath As String, DllFilePath2 As String
DllFileName = Parent.d_FileName
DllFilePath = Parent.d_DownloadName(0)
Dim DllFileName As Variant
Dim DllFilePath As String, DllFilePath2 As String
DllFileName = Parent.d_FileName
DllFilePath = Parent.d_DownloadName(0)
'--メール文書作成
Set MyMemo = db.CreateDocument
MyMemo.Form = "Memo"
Set MyRich = New NotesRichTextItem(MyMemo, "Body")
'--DLファイルを添付(WSHで一度ローカルにコピーし、添付を実施)
Forall x In DllFileName
DllFilePath2 = DllFilePath + "\" + Cstr(x)
newFile = "c:\data\" + Cstr(x)
If oWSH.FileExists(DllFilePath2)=True Then
oWSH.CopyFile DllFilePath2, "c:\data\"
Call MyRich.EmbedObject(EMBED_ATTACHMENT, "", newFile)
'--処理が終わったファイルをローカルから削除
oWSH.DeleteFile newFile, True
End If
End Forall
Call MyMemo.Send(False, Parent.SendTo(0))
Set MyMemo = db.CreateDocument
MyMemo.Form = "Memo"
Set MyRich = New NotesRichTextItem(MyMemo, "Body")
'--DLファイルを添付(WSHで一度ローカルにコピーし、添付を実施)
Forall x In DllFileName
DllFilePath2 = DllFilePath + "\" + Cstr(x)
newFile = "c:\data\" + Cstr(x)
If oWSH.FileExists(DllFilePath2)=True Then
oWSH.CopyFile DllFilePath2, "c:\data\"
Call MyRich.EmbedObject(EMBED_ATTACHMENT, "", newFile)
'--処理が終わったファイルをローカルから削除
oWSH.DeleteFile newFile, True
End If
End Forall
Call MyMemo.Send(False, Parent.SendTo(0))
参照
- Re: 添付ファイルの編集について(by ドミノ懇談室(2006~))
#作成者:Notes 野郎 (Yaroh Notes) 2007/2/23 (金) 午後 02:40
キーボードの操作で、
メニューバーの「添付ファイル」-「編集」
の操作を式かLotusScriptで記述するにはどのようにすればいいのでしょうか?
#作成者:すー しーほー (Su Syhoo) 2007/2/26 (月) 午後 04:56
NotesでSendkeys使えます。ただしクライアントはwindows限定です。方法は、
Dim oWSH
Set oWSH = CreateObject("Wscript.Shell")
oWSH.sendkeys "%TE"
formのアクションに上記をコーディング後、
添付ファイルを選択してこのアクションを実行すればOKです。
keybd_eventより楽なので最近はこれ。