VBA展望预约 [英] VBA Outlook Appointment

查看:166
本文介绍了VBA展望预约的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在尝试将数据从Excel复制到Outlook约会项目。我已经创建了一个带有表格和一些图像的模板,并希望从模板正文中格式化的表格中的excel文件复制数据。但是,与电子邮件不同的是,outlook约会不支持htmlbody属性,因此难以将模板粘贴到模板中。



到目前为止,我试图这样做:

  Dim olAppItem as Outlook.AppointmentItem 
设置olAppItem = olApp.CreateItemFromTemplate(C:\Users\User1\Desktop\Invite.oft)

以下两行是我遇到问题的地方。

  olAppItem.BodyFormat = olFormatRichtext 
olAppItem.RTFBody = Replace(olAppItem.RTFBody,%1%,Test,,,vbDatabaseCompare)

我已经尝试将 olAppItem.Bodyformat 设置为 olformatHTML ,但它不支持该属性。



任何帮助都不胜感激。



谢谢。

  Private Sub Add_Appointments_To_Outlook_Cale ndar()

'从工具中包含Microsoft Outlook nn.nn对象库 - >参考
Dim oAppt As AppointmentItem
Dim Remind_Time As Double

i = 2
Subj = ThisWorkbook.Sheets(1).Cells(i,1)

'循环遍历要添加的提醒的整个列表
虽然Subj<>
设置oAppt = Outlook.Application.CreateItem(olAppointmentItem)

oAppt.Subject = Subj
oAppt.Location = ThisWorkbook.Sheets(1).Cells(i,2 )
oAppt.Start = ThisWorkbook.Sheets(1).Cells(i,3)
Remind_Time = ThisWorkbook.Sheets(1).Cells(i,4)* 1 * 60
oAppt .ReminderMinutesBeforeStart = Remind_Time
oAppt.AllDayEvent = True
oAppt.Save

i = i + 1
Subj = ThisWorkbook.Sheets(1).Cells(i,1 )
Wend
MsgBox提醒添加到Outlook日历

End Sub

'代码来自此链接:

http://officetricks.com/add-appointment-to-outlook-calendar-through-excel-macro-vba/



我写了一本关于这些东西的书,还有很多其他类似但不同的东西。请从下面的链接中查看。



https://www.amazon.com/Automating-Business-Processes-Reducing-Increasing-ebook/dp/B01DJJKVZC?ie=UTF8&keywords=ryan%20shuell&qid=1463833985&ref_=sr_1_1&sr=8-1


I am trying to copy data from Excel to Outlook appointment Item. I have already created a template with a table and some images and would like the data to be copied from the excel file in the already formatted table in the body of the template. However, unlike e-mail, outlook appointment does not support ".htmlbody" property hence, its getting difficult to paste the data in the template.

So far, I am trying to do this:

Dim olAppItem as Outlook.AppointmentItem
Set olAppItem = olApp.CreateItemFromTemplate("C:\Users\User1\Desktop\Invite.oft")

The below two lines is where I am having a problem.

olAppItem.BodyFormat = olFormatRichtext
olAppItem.RTFBody = Replace(olAppItem.RTFBody, "%1%", "Test", , , vbDatabaseCompare)

I have tried setting olAppItem.Bodyformat to olformatHTML as well but it does not support the property.

Any help is appreciated.

Thanks.

解决方案

Please try this.

Private Sub Add_Appointments_To_Outlook_Calendar()

    'Include Microsoft Outlook nn.nn Object Library from Tools -> References
    Dim oAppt As AppointmentItem
    Dim Remind_Time As Double

    i = 2
    Subj = ThisWorkbook.Sheets(1).Cells(i, 1)

    'Loop through entire list of Reminders to be added
    While Subj <> ""
        Set oAppt = Outlook.Application.CreateItem(olAppointmentItem)

        oAppt.Subject = Subj
        oAppt.Location = ThisWorkbook.Sheets(1).Cells(i, 2)
        oAppt.Start = ThisWorkbook.Sheets(1).Cells(i, 3)
        Remind_Time = ThisWorkbook.Sheets(1).Cells(i, 4) * 1 * 60
        oAppt.ReminderMinutesBeforeStart = Remind_Time
        oAppt.AllDayEvent = True
        oAppt.Save

        i = i + 1
        Subj = ThisWorkbook.Sheets(1).Cells(i, 1)
    Wend
    MsgBox "Reminder(s) Added To Outlook Calendar"

End Sub

' The code comes from this link:

http://officetricks.com/add-appointment-to-outlook-calendar-through-excel-macro-vba/

I wrote a book about these kinds of things, and a lot of other similar but different things. Check it out from the link below.

https://www.amazon.com/Automating-Business-Processes-Reducing-Increasing-ebook/dp/B01DJJKVZC?ie=UTF8&keywords=ryan%20shuell&qid=1463833985&ref_=sr_1_1&sr=8-1

这篇关于VBA展望预约的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆