用于 Outlook 的脚本宏以查找文件夹 [英] Scripting Macro for Outlook to Find a Folder
问题描述
自动化此功能的最佳方法是什么?
What's the best way to automate this function?
我希望能够在 Outlook 2010 中执行此操作,
I want to be able to do this in Outlook 2010,
(1)选择一个特定的邮件账户(2)键入我要查找的文件夹(3)然后让宏/程序触发*"星号(4)然后插入我在第一步中键入的文本.
(1)select a specific mail account (2)Key in a folder that I am looking for (3)Then have the macro/program fire off an "*" asterisk (4)Then insert the text that I keyed in step one.
我正在尝试自动搜索已存在的文件夹热键.
I am trying to automate the search for a folder hot-keys that already exist.
我的问题是我无法足够快地输入我要查找的文件夹,而且我使用的所有搜索程序都太慢了.热键搜索很棒而且速度超快,我只是无法足够快地输入我要查找的文件夹.这个过程可以自动化吗?
My problem is that I can't type the folder that I am looking for fast enough and all the search programs that I have used are far too slow. The hot-key search is awesome and super fast, I just can't type the folder that I am looking for fast enough. Can this process be automated?
推荐答案
假设以\"为分隔符,您将需要将文件夹名称拆分为字符串列表或数组,然后为每个元素递归检索下一个子元素文件夹.与 basher 建议的类似,但有一个重要区别 - 绝对没有理由遍历所有子文件夹:OOM 中的 Folders.Item 采用整数索引(1 到 Count)或子文件夹名称.
Assuming "\" as a separator, you will need to split the folder name into a list or array of strings and then for each element recursively retrieve the next child folder. Similar to what basher suggested, but with one crucial difference - there is absolutely no reason to loop through all subfolders: Folders.Item in OOM takes either an integer index (1 through Count) or the subfolder name.
例如Subfolder = Folder.Folders.Item("Some name") 将检索名为Some name"的子文件夹.
E.g. Subfolder = Folder.Folders.Item("Some name") will retrieve a subfolder named "Some name".
示例脚本(VBA):
strFolderPath = "Subfolder 1\Subfolder 2"
FolderNames = Split(strFolderPath, "\")
'aassuming the path is relative to the currently displayed folder
'or use a top level folder
set RootFolder = Application.ActiveExplorer.CurrentFolder
set CurrentFolder = RootFolder
for each subFolderName in FolderNames
set CurrentFolder = CurrentFolder.Folders.Item(subFolderName)
next
Debug.Print CurrentFolder.Name
这篇关于用于 Outlook 的脚本宏以查找文件夹的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!