Excel VBA help with setting appointment in outlook multiple times with one macro button

jackson1990

Board Regular
Joined
Feb 21, 2017
Messages
56
Everyone has been so helpful on here, so thanks so far for that!

So, I have some code to cause an outlook appointment to be populated with information from cell A2 and E14. Which works as designed, but I want to use this single macro multiple times on the same sheet. For example there is going to be 10 buttons all going down the sheet, A2 and E14 coordinate with the first block of information then it will be A15 and E26, then A27 and E38 and so on. Ideally I'd like for it to be dynamic somehow so it could search the title in a2 then a15 then a27. But I'm kind of having a block of how I would go about that? The reason behind this is so when I hand the project off to someone else who may not know VBA they are able to change the structure of the sheet without breaking the macro. If I simply make 10 buttons if they were to change where the title was from a2 to b2 then it would be broken and they'd be confused. Is there anyway I can accomplish this or is this impossible? I provided code below.

Code:
Sub EmailProp() 
  Dim oApp As Outlook.Application
  Dim oNameSpace As Namespace
  Dim oItem As AppointmentItem
      
  On Error Resume Next
  ' check if Outlook is running
  Set oApp = GetObject("Outlook.Application")
  If Err <> 0 Then
    'if not running, start it
    Set oApp = CreateObject("Outlook.Application")
  End If
  
  Set oNameSpace = oApp.GetNamespace("MAPI")
  
  Set oItem = oApp.CreateItem(olAppointmentItem)
  
  With oItem
  
    .Subject = Range("A2") + " Due"
    .Start = Range("E14")
    .Duration = "01:00"
    
    .AllDayEvent = True
    .Importance = olImportanceNormal
    
    
    .ReminderSet = True
    .ReminderMinutesBeforeStart = "10"


    
    Select Case 1 ' do you want to display the entry first or save it immediately?
      Case 1
        .Display
      Case 2
        .Save
    End Select
  
  End With
    
  Set oApp = Nothing
  Set oNameSpace = Nothing
  Set oItem = Nothing
     
End Sub
 

Excel Facts

Which came first: VisiCalc or Lotus 1-2-3?
Dan Bricklin and Bob Frankston debuted VisiCalc in 1979 as a Visible Calculator. Lotus 1-2-3 debuted in the early 1980's, from Mitch Kapor.
Any ideas or help on this folks? Would be appreciated. Don't know if my thought process is just off or it wouldn't be possible.
 
Upvote 0

Forum statistics

Threads
1,224,823
Messages
6,181,181
Members
453,022
Latest member
Mohamed Magdi Tawfiq Emam

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