以下のコードは、Outlookの[選択済み]メールの添付ファイル[]を[マイドキュメント]フォルダに保存します。Cドライブの "specialfolders(16)"からXYZフォルダへのパスを変更するにはどうすればよいですか?
sFolderPath = objWSCript.specialfolders(16)
の場所をCドライブの「新規フォルダ」フォルダに変更する方法を教えてください。
Option Explicit
Sub SaveAttchFiles()
Dim olMail As MailItem
Dim olAtchs As Attachments
Dim olSelection As Selection
Dim iCount As Long, i As Long
Dim sFolderPath As String, sFilePath As String, sDeletedFiles As String
Dim objWSCript As Object
On Error Resume Next
Set objWSCript = CreateObject("WSCript.Shell")
sFolderPath = objWSCript.specialfolders(16)
Set olSelection = ActiveExplorer.Selection
sFolderPath = sFolderPath & "\New Folder\"
For Each olMail In olSelection
Set olAtchs = olMail.Attachments
iCount = olAtchs.Count
sDeletedFiles = ""
If iCount > 0 Then
For i = iCount To 1 Step -1
sFilePath = sFolderPath & olAtchs.Item(i).FileName
olAtchs.Item(i).SaveAsFile sFilePath
Next i
End If
Next olMail
Door:
Set objWSCript = Nothing
Set olAtchs = Nothing
Set olSelection = Nothing
End Sub
'sFolderPath = "C:\ MyFolderを\"'で – ACatInLove
..asは、あなたが** **新しいフォルダを作成したい、またはフォルダです** ** "新しいフォルダ"と呼ばれる? – ashleedawg
またはダイアログボックスからフォルダを選択しますか? –