gpt4 book ai didi

vba - Outlook 2010 创建文件夹和子文件夹

转载 作者:行者123 更新时间:2023-12-01 19:20:46 24 4
gpt4 key购买 nike

我有这段代码,可以在当前选定的文件夹下创建一系列文件夹:

Public Sub CreateFolders()
Dim CurrentFolder As Outlook.MAPIFolder
Dim Subfolder As Outlook.MAPIFolder
Dim List As New VBA.Collection
Dim Folders As Outlook.Folders
Dim Item As Variant

List.Add Array("Audio Video Graphics", olFolderInbox)
List.Add Array("Close Out", olFolderInbox)
List.Add Array("Correspondence", olFolderInbox)
List.Add Array("Expenditure Adjustments", olFolderInbox)
List.Add Array("Invoices", olFolderInbox)
List.Add Array("Project Schedule", olFolderInbox)
List.Add Array("RADPARs and Contracts", olFolderInbox)
List.Add Array("REQs and POs", olFolderInbox)
List.Add Array("Technical Information", olFolderInbox)

Set CurrentFolder = Application.ActiveExplorer.CurrentFolder
Set Folders = CurrentFolder.Folders
For Each Item In List
Folders.Add Item(0), Item(1)
Next
End Sub

我想要做的是在“REQs and POs”文件夹下添加一个名为 Proposal 的子文件夹。

这用于在公用文件夹上创建文件夹。我以前从未在 VBA 中进行过编码,并且一直无法弄清楚如何添加子文件夹。

我在网上查了一下,但没有找到任何东西。

任何帮助将不胜感激。

最佳答案

试试这个。

Public Sub CreateFolders()
Dim CurrentFolder As Outlook.MAPIFolder
Dim Subfolder As Outlook.MAPIFolder
Dim List As New VBA.Collection
Dim Folders As Outlook.Folders
Dim Item As Variant

List.Add Array("Audio Video Graphics", olFolderInbox)
List.Add Array("Close Out", olFolderInbox)
List.Add Array("Correspondence", olFolderInbox)
List.Add Array("Expenditure Adjustments", olFolderInbox)
List.Add Array("Invoices", olFolderInbox)
List.Add Array("Project Schedule", olFolderInbox)
List.Add Array("RADPARs and Contracts", olFolderInbox)
List.Add Array("REQs and POs", olFolderInbox)
List.Add Array("Technical Information", olFolderInbox)

Set CurrentFolder = Application.ActiveExplorer.CurrentFolder
Set Folders = CurrentFolder.Folders
For Each Item In List
Folders.Add Item(0), Item(1)
Next

Set Folders = CurrentFolder.Folders.Item("REQs and POs").Folders

' or simply
'Set Folders = CurrentFolder.Folders("REQs and POs").Folders

Folders.Add "Proposal", olFolderInbox

End Sub

关于vba - Outlook 2010 创建文件夹和子文件夹,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/31058057/

24 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com