如何在一个Office Automation的程序中获取Shared Calendars
2012-02-24 09:32
190 查看
Imports Outlook = Microsoft.Office.Interop.Outlook Public Class Form1 Private OLApp As Outlook.Application Private OlExplorer As Outlook.Explorer Private OlNavigationPan As Outlook.NavigationPane Private CalendarModule As Outlook.CalendarModule Private OlNavigationGroup As Outlook.NavigationGroup Private Sub Form1_Load(sender As System.Object, e As System.EventArgs) _ Handles MyBase.Load Dim Process() As System.Diagnostics.Process = System.Diagnostics _ .Process.GetProcessesByName("OUTLOOK") If Process.Length > 0 Then OLApp = System.Runtime.InteropServices.Marshal _ .GetActiveObject("Outlook.Application") Else OLApp = New Outlook.Application End If If OLApp.ActiveExplorer IsNot Nothing Then OlExplorer = OLApp.ActiveExplorer Else OlExplorer = OLApp.Explorers.Add(OLApp.Session _ .GetDefaultFolder(Outlook.OlDefaultFolders.olFolderInbox)) OlExplorer.Activate() End If OlNavigationPan = OlExplorer.NavigationPane CalendarModule = OlNavigationPan.Modules _ .GetNavigationModule(Outlook.OlNavigationModuleType. _ olModuleCalendar) ComboBox1.Items.Clear() OlNavigationGroup = CalendarModule.NavigationGroups("Shared Calendars") If OlNavigationGroup IsNot Nothing Then For Each Folder As Outlook.NavigationFolder In OlNavigationGroup _ .NavigationFolders ComboBox1.Items.Add(Folder.DisplayName) Next Else MsgBox("OlNavigationGroup is nothing") End If End Sub Private Sub Form1_FormClosed(sender As System.Object, e As System.Windows _ .Forms.FormClosedEventArgs) Handles MyBase.FormClosed If OLApp IsNot Nothing Then System.Runtime.InteropServices.Marshal.ReleaseComObject(OLApp) End If End Sub Private Sub Button1_Click(sender As System.Object, e As System.EventArgs) _ Handles Button1.Click Dim OlNavigationFolder As Outlook.NavigationFolder If OlNavigationGroup IsNot Nothing Then OlNavigationFolder = OlNavigationGroup _ .NavigationFolders(ComboBox1.SelectedIndex + 1) If OlNavigationFolder IsNot Nothing Then OlNavigationPan.CurrentModule = CalendarModule OlNavigationFolder.IsSelected = True End If Else MsgBox("OlNavigationGroup is nothing") End If End Sub End Class
Shared Calendar 的 MAPIFolder是没有办法获得的。我们只能获得NavigationFolder。
相关资源:http://download.csdn.net/detail/tx_officedev/4086064
相关文章推荐
- android 如何获取一个程序的当前版本号
- 如何在一个Office Automation的程序中获取Shared Calendars
- JAVA 程序中如何拷贝一个目录下的文件及子目录到另一个目录,如何获取系统环境变量等...
- SQLSERVER如何获取一个数据库中的所有表的名称、一个表中所有字段的名称
- c#检查程序是否已经运行,如何防止多次运行同一个程序?
- 通过一个简单的例子学习编译器是如何执行程序的
- 【题目6】如何设计一个可以获取最小值的栈
- 如何精确计算程序运行时间——精确获取时间(QueryPerformanceCounter)
- 014写程序将一个栈按升序排序,对这个栈是如何实现的,你不应该做任何特殊的假设(keep it up)
- 如何在其它程序窗口(已知窗口的句柄)加上一个按钮
- 如何编写一个自动投票程序
- 如何判断一个程序没有响应
- windows 上一个.exe程序是如何运行的
- ios中如何用一个格式获取多个文件目录中的全部文件
- java程序如何获取命令行参数
- inno setup软件--教你如何制作一个漂亮的安装程序
- Delphi 如何让程序获取权限结束指定进程?
- 如何编写一个自动投票程序
- 在jsp页面如何获取Map里面某一个指定集合的值并循环打印
- 如何安装一个屏幕保护程序