vba - 在通讯录宏中查找替换
问题描述
我正在尝试构建一个宏来删除散布在 MS Outlook 联系人备注字段中的一系列电子邮件。这是我到目前为止所拥有的,当它执行时,似乎没有任何可见的事情发生。感谢任何反馈。电子邮件看起来像<name@xyz.com>
Sub OutlookDeleteTextBetween()
Dim olInspector As Outlook.Inspector
Dim olDocument As Word.Document
Dim olSelection As Word.Selection
Set olInspector = Application.ActiveInspector()
Set olDocument = olInspector.WordEditor
Set olSelection = olDocument.Application.Selection
olSelection.WholeStory
With olSelection.Find
.Text = "\<*\>"
.MatchWildcards = True
.Replacement.Text = ""
.Execute Replace:=wdReplaceAll
End With
End Sub
解决方案
删除散布在 MS Outlook 联系人备注字段中的一系列电子邮件
进行一些更改后尝试Save
邮件项目。在您保存项目或重新打开窗口之前,Outlook 可能不会传播更改。
如果您需要查找附加的邮件项目,它们将作为附件存储在 Outlook 项目中。在您看来,您需要检查Attachments
集合并使用Attachments.Remove方法从集合中删除对象。例如:
Sub RemoveAttachmentBeforeForwarding()
Dim myinspector As Outlook.Inspector
Dim myItem As Outlook.MailItem
Dim myattachments As Outlook.Attachments
Set myinspector = Application.ActiveInspector
If Not TypeName(myinspector) = "Nothing" Then
Set myItem = myinspector.CurrentItem.Forward
Set myattachments = myItem.Attachments
While myattachments.Count > 0
myattachments.Remove 1
Wend
myItem.Display
myItem.Recipients.Add "Eugene Astafiev"
myItem.Send
Else
MsgBox "There is no active inspector."
End If
End Sub
推荐阅读
- google-cloud-platform - BigQuery 哈希索引功能
- java - Android 的 Calendar.Day_Of_Month 是从零开始的吗?
- java - 如何在 App Engine Flex Java 环境中使用 Stackdriver 结构化日志记录
- python - 如何映射两个数组的值并返回映射值的索引
- c++ - 自定义函数可以存储在库中并用于基本数据类型/C++ 吗?
- python - Python Twitter 情绪分析损失/准确率没有变化
- r - 在 R 中对复杂的嵌套 for 循环进行矢量化(在数据集的不同子集上运行模型,为每个循环设置不同的数据子集)
- javascript - 如何为 Ng 重复指令访问的视图中的每个项目创建查看更多切换
- java - 看不到控制台中打印的数组内容
- html - @ 媒体最大宽度无法正常工作