首页
学习
活动
专区
圈层
工具
发布
首页
学习
活动
专区
圈层
工具
MCP广场
社区首页 >问答首页 >将共享组Outlook日历约会导入Excel

将共享组Outlook日历约会导入Excel
EN

Stack Overflow用户
提问于 2019-05-13 20:27:16
回答 1查看 109关注 0票数 0

我希望将共享组Outlook日历中的约会导入Excel。

我使用了GetSharedDefaultFolder,但是收到了以下错误:

无法打开邮箱,因为此通讯簿项与电子邮件用户不匹配。

代码语言:javascript
运行
复制
Sub ResolveName()
    ' déclaration des variables
    Dim outlookApp As Outlook.Application
    Dim myNamespace As Outlook.Namespace
    Dim myRecipient As Outlook.Recipient
    Dim CalendarFolder As Outlook.folder
    Dim calendarApp As Outlook.AppointmentItem
    Dim calendarItem As Outlook.Items
    Dim i As Long
        
    Set outlookApp = New Outlook.Application
    Set myNamespace = outlookApp.GetNamespace("MAPI")
    Set myRecipient = myNamespace.CreateRecipient("dp-TECCR-FormationdesrepartiteursCCRediteurs@hydro.qc.ca")
    i = 2
        
    myRecipient.Resolve
    Range("A1:D1").Value = Array("Subject", "from", "date", "location")
    If myRecipient.Resolved Then
        Set CalendarFolder = myNamespace.GetSharedDefaultFolder(myRecipient, olFolderCalendar)
        For Each calendarApp In CalendarFolder.Items
            Cells(i, 1).Value = calendarItem.Subject
            Cells(i, 2).Value = calendarItem.Start
            Cells(i, 3).Value = calendarItem.End
            Cells(i, 4).Value = calendarItem.Location
            Cells(i, 5).Value = calendarItem.MeetingStatus
            i = i + 1
        Next
    End If
        
    Set outlookApp = Nothing
    Set myNamespace = Nothing
    Set myRecipient = Nothing
    Set CalendarFolder = Nothing
    Set calendarItem = Nothing
End Sub
EN

回答 1

Stack Overflow用户

发布于 2019-08-17 12:11:48

当您使用电子邮件地址时,解决方案什么也不做。

如果要跟踪有用的CreateRecipient,请在If myRecipient.Resolved Then中使用display /其他名称属性。

代码语言:javascript
运行
复制
Option Explicit

Sub ResolveName()
    ' déclaration des variables
    Dim outlookApp As Outlook.Application
    Dim myNamespace As Outlook.Namespace
    Dim myRecipient As Outlook.Recipient
    Dim CalendarFolder As Outlook.Folder
    Dim calendarApp As Outlook.AppointmentItem
    Dim calendarItem As Outlook.Items
    Dim i As Long

    Set outlookApp = New Outlook.Application
    Set myNamespace = outlookApp.GetNamespace("MAPI")
    Set myRecipient = myNamespace.CreateRecipient("nothingvalid@hydro.qc.ca")
    i = 2

    myRecipient.Resolve
    'Range("A1:D1").Value = Array("Subject", "from", "date", "location")
    If myRecipient.Resolved Then
        Debug.Print "Anything that looks like an email address will Resolve."
        Debug.Print "Use display name / other name property."
        'Set CalendarFolder = myNamespace.GetSharedDefaultFolder(myRecipient, olFolderCalendar)
        'For Each calendarApp In CalendarFolder.Items
        '    Cells(i, 1).Value = calendarItem.Subject
        '    Cells(i, 2).Value = calendarItem.Start
        '    Cells(i, 3).Value = calendarItem.End
        '    Cells(i, 4).Value = calendarItem.Location
        '    Cells(i, 5).Value = calendarItem.MeetingStatus
        '    i = i + 1
       ' Next
    End If

    Set outlookApp = Nothing
    Set myNamespace = Nothing
    Set myRecipient = Nothing
    Set CalendarFolder = Nothing
    Set calendarItem = Nothing
End Sub
票数 0
EN
页面原文内容由Stack Overflow提供。腾讯云小微IT领域专用引擎提供翻译支持
原文链接:

https://stackoverflow.com/questions/56119457

复制
相关文章

相似问题

领券
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档