VBA posting double entries in Outlook

hetterbr

Board Regular
Joined
Jul 8, 2011
Messages
56
I have the below VBA formula created. It takes entries from Excel and enters them as a meeting request in Micro Soft Outlook. It works quite well, however, everytime I run it, it enters all of the meeting requests again. I am look for a way to have it not double post entries every time I run it.


Private Sub AddToOLCalendar()

Dim objOL As Object
Dim objItem As Object
Dim lngRow As Long

Set objOL = CreateObject("Outlook.Application")

lngRow = 1
Do While ActiveSheet.Cells(lngRow, 1) <> ""
If ActiveSheet.Cells(lngRow, 2).Text <> "" Then
Set objItem = objOL.CreateItem(1) ' constant olAppointmentItem = 2

With objItem
.Body = Cells(lngRow, "C").Value
.Duration = 15
.Start = Cells(lngRow, "A").Value & " 9:00:00 AM"
.Subject = Cells(lngRow, "B").Value
.Save
End With
End If
lngRow = lngRow + 1
Loop
Set objItem = Nothing
Set objOL = Nothing

End Sub
Private Sub Worksheet_SelectionChange(ByVal Target As Range)
End Sub
 

Excel Facts

Remove leading & trailing spaces
Save as CSV to remove all leading and trailing spaces. It is faster than using TRIM().

Forum statistics

Threads
1,224,566
Messages
6,179,550
Members
452,927
Latest member
rows and columns

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