outlook2016把日历导出html,如何将Outlook日历导出到Excel每周时间表?

R3uK..

10

一个简单的谷歌搜索,一点点重构:

Option Explicit

Sub ListAppointments()

Dim olApp As Object

Dim olNS As Object

Dim olFolder As Object

Dim olApt As Object

Dim NextRow As Long

Dim FromDate As Date

Dim ToDate As Date

FromDate = CDate("08/25/2017")

ToDate = CDate("12/31/2017")

On Error Resume Next

Set olApp = GetObject(, "Outlook.Application")

If Err.Number > 0 Then Set olApp = CreateObject("Outlook.Application")

On Error GoTo 0

Set olNS = olApp.GetNamespace("MAPI")

Set olFolder = olNS.GetDefaultFolder(9) 'olFolderCalendar

NextRow = 2

With Sheets("Sheet1") 'Change the name of the sheet here

.Range("A1:D1").Value = Array("Project", "Date", "Time spent", "Location")

For Each olApt In olFolder.Items

If (olApt.Start >= FromDate And olApt.Start <= ToDate) Then

.Cells(NextRow, "A").Value = olApt.Subject

.Cells(NextRow, "B").Value = CDate(olApt.Start)

.Cells(NextRow, "C").Value = olApt.End - olApt.Start

.Cells(NextRow, "C").NumberFormat = "HH:MM:SS"

.Cells(NextRow, "D").Value = olApt.Location

.Cells(NextRow, "E").Value = olApt.Categories

NextRow = NextRow + 1

Else

End If

Next olApt

.Columns.AutoFit

End With

Set olApt = Nothing

Set olFolder = Nothing

Set olNS = Nothing

Set olApp = Nothing

End Sub

这在Office 2016中仍然运行良好!我添加了这一行:`.Cells(NextRow,"E").Value = olApt.Categories`如果你想为不同的项目分类你的会议等. (2认同)

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值