English 中文(简体)
特定类别
原标题:Block calendar entry with specific categories
  • 时间:2020-01-07 10:30:35
  •  标签:
  • vba
  • outlook

I have a Meeting / Appointment item and make this form available with a set category.
I would like to decide which of them I enter in my calendar.

我有工作守则,以确定我的具体类别。

  Outputs all elements without set category
Sub SearchCategoryRestriction()
 Dim myFolder As Outlook.Folder
 Dim myItems As Outlook.Items
 Dim Filter As String
 Dim myNamespace As Namespace
 
  This will return all items that have the set category.
 Filter = "[Categories] =  myKeyword "
 Set myNamespace = GetNamespace("MAPI")
 Set myFolder = myNamespace.GetDefaultFolder(olFolderInbox)
 Set myItems = myFolder.Items.Restrict(Filter)
 Debug.Print myItems.Count

End Sub

当我发现该项目时,我希望看到任命能够决定我是否想在我的日历上加上该项目。

Maybe I found a solution https://support.office.com/en-us/article/Show-a-declined-meeting-on-my-calendar-24E81B9B-3906-4C02-8B63-F97B02161763.
If I delete all income items with my set categories, I hope they will not be added to my calendar.
Then I run the search script to find it in the list of objects to be deleted and show it to the user.

问题回答

First of all, I d suggest using Instr function instead of comparing strings. The Categories string may contain other markers, not only your single one.

不清楚用什么法典搜寻有特定类别组的物品,最可能的话,你只是对纸浆中所有不好的物品 it。 相反,你需要使用<代码>Find/FindNextRestrict方法,只接收符合您条件的项目。 例如:

Sub MoveItems()  
    Dim myNamespace As Outlook.NameSpace  
    Dim myFolder As Outlook.Folder  
    Dim myItems As Outlook.Items  
    Dim myRestrictItems As Outlook.Items  
    Dim myItem As Outlook.MailItem  

    Set myNamespace = Application.GetNamespace("MAPI")  
    Set myFolder = _  
        myNamespace.GetDefaultFolder(olFolderInbox)  
    Set myItems = myFolder.Items  
    Set myRestrictItems = myItems.Restrict("[Categories] =  testword ")  
      do whatever you need with items found, for example, move to a subfolder
    For i =  myRestrictItems.Count To 1 Step -1  
        myRestrictItems(i).Move myFolder.Folders("Business")  
    Next  
End Sub

<代码>Categories field is of category keywords, which is aiming to hold multi Value. 在从方案角度看,<代码>Categories field behaves as a Text field, 并且脚步必须完全一致。 案文载体中的数值由 com和空间分开。 这通常意味着,如果含有一个以上价值的话,你不能使用<代码>Find和关于关键词的限制性方法。 例如,如果您在商业类别中有一个联系,在企业和社会类别上有一个联系,那么你就无法轻易使用<代码>Find和Restrict方法检索所有属于商业类别的项目。 相反,你可以通过文件夹中的所有接触,并使用<条码>。

可能的例外是,如果你将<代码>Categories field限制在两个或两个低数值上。 然后,可使用<代码>Find和>Restrict方法,由OR的逻辑操作者检索所有物项。 例如(在假体编码中):“企业”或“企业、个人”或“个人”

注意<代码> 类别指示对个案不敏感。

在以下条款中更多地了解这些方法:

也可找到。 方法有用。 使用<代码>先进Search的主要好处 展望的方法是:





相关问题
Handling no results for docmd.applyfilter

I have an Access app where I use search functionality. I have a TextBox and a Search Button on the form, and it does a wildcard search of whatever the user enters in the TextBox, and displays the ...

Outlook 2007 CommandBarControl.Execute won t work

I recently switched to Outlook 2007 and noticed that my VBA-macros won t work. I use the following code to open a new appointment-item (and fill it automatically). It worked perfect in Outlook 2003, ...

Connecting to Oracle 10g with ODBC from Excel VBA

The following code works. the connection opens fine but recordset.recordCount always returns -1 when there is data in the table. ANd If I try to call any methods/properties on recordset it crashes ...

MS Access: list macro from VBA

I have to deal with a few macros (not VBA) in an inherited Access application. In order to document them, I would like to print or list the actions in those macros, but I am very dissatisfied by ...

热门标签