現在、添付ファイルの名前をSubjectとして使用するOutlookでマクロを使用しています。VBA(Outlook 2010)を使用してテキストの一部を削除する
マクロがある:
Sub AttachmentNameAsSubject()
Dim AttachmentName As String
Dim currItem As Object
Set currItem = ActiveInspector.CurrentItem
With currItem
If .Attachments.Count > 0 Then
AttachmentName = .Attachments.Item(1).DisplayName
.Subject = AttachmentName
End If
End With
End Sub
添付ファイルがある場合にアタッチメントは、典型的には、PDFファイルまたは.xlsファイルのいくつかの種類である:「MyAttachment.pdf」、件名が「MyAttachment.pdfを読み取り"
件名の行が「MyAttachment」と単に読み込まれ、「.pdf」などの拡張子が含まれないように、件名の末尾にテキストを削除する方法はありますか。
あなたが使用Left関数:左(.Attachments.Item(1).DisplayName、レン(.Attachments.Item(1).DisplayName) - 4) – Sorceri
拡張は4つの以上の文字とすることができる場合InStr(1、.Attachments.Item(1).DisplayName、 "。") - 1) – Sorceri
これはちょうど依存しています内線でほとんどの場合、拡張子が4文字(「.pdf」などのピリオドを含む)であると感じます。それ以外の時間は5-7文字です。 – Darren