如何将“specialfolders(16)”的路径更改为C盘上的XYZ文件夹?

问题描述 投票:1回答:1

下面的代码保存Outlook中“选定”电子邮件的附件[到“我的文档”文件夹]。

你能否告诉我如何将sFolderPath = objWSCript.specialfolders(16)的位置更改为C盘上的“New Folder”文件夹?

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
vba outlook
1个回答
1
投票

真?你有一个名为新文件夹的文件夹?它在另一个名为All Folders的文件夹中?男孩哦男孩....

无论如何,如果真的如此,那么你只需要改变:

sFolderPath = sFolderPath & "\New Folder\"

...至...

sFolderPath = "C:\All Folders\New Folder\"

作为奖励,请查看:

© www.soinside.com 2019 - 2024. All rights reserved.