dポイントプレゼントキャンペーン実施中!

Outlookで、予定の件名をVBAから書き換えたいのですが
うまくいきません。
環境は、OS:Win2000、Ver: Outlook2000 SP3です(古いですが)。

今のところ、ネット上で拾ったコードを元に、

Dim colAppts As Items

Set colAppts = Application.Session.GetDefaultFolder(olFolderCalendar).Items
For i = 1 To colAppts.Count
MsgBox colAppts.Item(i).Subject
colAppts.Item(i).Subject = "ほげ"
colAppts.Item(i).Save
MsgBox colAppts.Item(i).Subject
Next

というようなことをやってみたのですが、Subjectプロパティへの代入前後で、
内容がまったく変わりません。
どうやったらいいのでしょうか?

A 回答 (2件)

以下でどうでしょうか?



Dim colAppts As Items
Dim apptItem As Appointmentitem

Set colAppts = Application.Session.GetDefaultFolder(olFolderCalendar).Items
For i = 1 To colAppts.Count
Set apptItem = colAppts(i)
MsgBox apptItem.Subject
apptItem.Subject = "ほげ"
apptItem.Save
MsgBox apptItem.Subject
Next
    • good
    • 0
この回答へのお礼

カンペキです。
いったんAppointmentitemオブジェクトに書き出すのがポイントなんですね。

ありがとうございました。

お礼日時:2010/06/14 14:42

こんな風にしたらいかがでしょうか?



Sub OutlookTest1()
  Dim colAppts As Items
  Set colAppts = Application.Session.GetDefaultFolder(olFolderCalendar).Items
  For i = 1 To colAppts.Count
    MsgBox colAppts.Item(i).Subject
    colAppts.Item(i).Display
    colAppts.Item(i).Subject = "ほげ"
    colAppts.Item(i).Close olSave
    MsgBox colAppts.Item(i).Subject
  Next
End Sub
    • good
    • 0
この回答へのお礼

すみません。環境の違いかもしれませんが、
私のところではこれでは前後で変化なしでした。

ご回答ありがとうございました。

お礼日時:2010/06/14 14:43

お探しのQ&Aが見つからない時は、教えて!gooで質問しましょう!