删除上述某个集合中的一个对象。
expression.Remove(Index)
expression 必选。该表达式返回上述集合对象之一。
Index 必选,Long 类型。集合中对象的索引值。
应用于 Links、OutlookBarGroups、OutlookBarShortcuts、PropertyPages、Reminders 和 Views
对象的 Remove 方法。
从指定列表删除某个对象。
expression.Remove(Index)
expression 必选。该表达式返回上述对象之一。
Index 必选,Variant 类型。列表中对象的名称或序数。
本 Visual Basic for Applications 示例在将转发的邮件发送给 Jeff Smith 之前,使用 Remove 方法删除其中的所有附件。
Set myOlApp = CreateObject("Outlook.Application")
Set myItem = myOlApp.ActiveInspector.CurrentItem.Forward
Set myAttachments = myItem.Attachments
While myAttachments.Count > 0
myAttachments.Remove 1
Wend
myItem.Recipients.Add "Jeff Smith"
myItem.Send
如果使用 VBScript,则不必创建 Application 对象。本示例说明如何使用 VBScript 执行相同任务。
Set myItem = Application.ActiveInspector.CurrentItem.Forward
Set myAttachments = myItem.Attachments
While myAttachments.Count > 0
myAttachments.Remove 1
Wend
myItem.Recipients.Add "Jeff Smith"
myItem.Send
应用于 Links、OutlookBarGroups、OutlookBarShortcuts、PropertyPages、Reminders 和 Views 对象时。
Sub DeleteView()
'Deletes a view from the collection
Dim olApp As Outlook.Application
Dim objName As NameSpace
Dim objViews As Views
Dim objView As View
Dim strName As String
strName = "New Icon View"
Set olApp = Outlook.Application
Set objName = olApp.GetNamespace("MAPI")
Set objViews = objName.GetDefaultFolder(olFolderNotes).Views
For Each objView In objViews
If objView.Name = strName Then
objViews.Remove (strName)
End If
Next objView
End Sub