Outlook VBA

cstimart

Well-known Member
Joined
Feb 25, 2010
Messages
1,180
I am relatively new to VBA (self-taught) and have created some macros in Excel. However, I am now intrigued by the possibilities in Outlook (2007). Programming outside the "grid" of a spreadsheet seems very foreign to me at this time.

Is there a simple code that would prompt for a start date and then ask basic yes/no question for the individual weekdays (with an option to stop) and if "yes", enter an event on the calendar for that date?
 

Excel Facts

Quick Sum
Select a range of cells. The total appears in bottom right of Excel screen. Right-click total to add Max, Min, Count, Average.
checking it out now
ok here is the revised code with few lines taken out, which were to do with me setting up a data string saved to the clipboard for pasting into another application, my fault

'****
' procedure to assist in deletion of user accounts cutting down the keystrokes
' prompt for username(s) and create a calendar appointment
' copy a piece of text to the clipboard, to be pasted into Easy Vista Update box
'
' Author Jim Ward
' Creation 16th April 2010
'****
'
Sub DeleteAccountAppoint()
Dim EndDate As Date
Dim FutureDate As Date

'
'****
' Get a list of username(s)
'****
'
Dim strName As String

strName = InputBox(Prompt:="Enter User(s) To Be Deleted", _
Title:="ENTER USER(S) NAME", Default:="Users Name here")

If strName = "Users Name here" Or strName = vbNullString Then
Exit Sub
End If

'
'****
' Get Todays date, add 30 days
' check if saturday or sunday advance if needed to Monday
'****
'

FutureDate = Date + 30
wDay = Weekday(FutureDate, vbMonday)
If wDay = 6 Then
FutureDate = FutureDate + 2
End If
If wDay = 7 Then
FutureDate = FutureDate + 1
End If

'
'****
' Add 8 hours as the above sets to midnight, then add 15mins for 08:15
'****
'

FutureDate = FutureDate + TimeSerial(8, 0, 0)
EndDate = FutureDate + TimeSerial(0, 15, 0)

'
'****
' Create appointment and copy a constant string to the clipboard
'****
'

CreateAppointment "Account Deletion", "Delete Accounts for " + strName, FutureDate, EndDate, False

End Sub
'
'****
'Function to create calendar item, nabbed from my friend google
'****
'
Public Function CreateAppointment(SubjectStr As String, BodyStr As String, StartTime As Date, EndTime As Date, AllDay As Boolean)
Dim OlApp As Outlook.Application
Dim Appt As Outlook.AppointmentItem
Set OlApp = CreateObject("Outlook.Application")
Set Appt = OlApp.CreateItem(olAppointmentItem)
Appt.Subject = SubjectStr
Appt.Start = StartTime
Appt.End = EndTime
Appt.AllDayEvent = AllDay
Appt.Body = BodyStr
Appt.Save
Set Appt = Nothing
Set OlApp = Nothing
End Function
 
Last edited:
Upvote 0
I tried this code and I get the inputbox asking for the user name...no matter what I put in, nothing happens. :confused:
 
Upvote 0
check your outlook calender 30 days from today and see if you have a entry, this is controlled by the line futuredate = date + 30
 
Upvote 0
check your outlook calender 30 days from today and see if you have a entry, this is controlled by the line futuredate = date + 30

BINGO!

On a side note/question: Would you happen to know why it takes Outlook a long time to switch between Inboxes/Calendar/Contacts, etc..? I tried compacting the personal/archive folders...and no luck.

Cheers
 
Upvote 0
you could try a detect and repair under the help menu, but you may need your installation disk, apart from that no idea, what version are you running
 
Upvote 0
check your outlook calender 30 days from today and see if you have a entry, this is controlled by the line futuredate = date + 30

I started using this code as my beginning point. Is it possible to fill a Multilist Box with dates (let's say in January) that DON'T already have the entry?
 
Upvote 0

Forum statistics

Threads
1,225,535
Messages
6,185,503
Members
453,298
Latest member
Adam1258

We've detected that you are using an adblocker.

We have a great community of people providing Excel help here, but the hosting costs are enormous. You can help keep this site running by allowing ads on MrExcel.com.
Allow Ads at MrExcel

Which adblocker are you using?

Disable AdBlock

Follow these easy steps to disable AdBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the icon in the browser’s toolbar.
2)Click on the "Pause on this site" option.
Go back

Disable AdBlock Plus

Follow these easy steps to disable AdBlock Plus

1)Click on the icon in the browser’s toolbar.
2)Click on the toggle to disable it for "mrexcel.com".
Go back

Disable uBlock Origin

Follow these easy steps to disable uBlock Origin

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back

Disable uBlock

Follow these easy steps to disable uBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back
Back
Top