Using Access VBA to update Outlook

Collapse
X
 
  • Time
  • Show
Clear All
new posts
  • didacticone
    Contributor
    • Oct 2008
    • 266

    Using Access VBA to update Outlook

    I was curious if there is a way to use a form in access and send that data to the default outlook calendar as an appt. I have tried this code but it doesn't seem to work.

    Code:
    Dim olApp As Outlook.Application
      Dim objAppointment As Outlook.AppointmentItem
      Dim objAppointments As Outlook.MAPIFolder
      Dim objNameSpace As Outlook.NameSpace
      Dim objProperty As Outlook.UserProperty
      Dim OutlookStartTime, OutlookEndTime As Date
      Dim sFilter As Variant
     
      OutlookStartTime = CDate(ap_date & " " & ap_start_time)
      OutlookEndTime = CDate(ap_date & " " & AP_End_Time)
     
      Set olApp = CreateObject("Outlook.Application")
      Set objNameSpace = olApp.GetNamespace("MAPI")
      Set objAppointments = objNameSpace.GetDefaultFolder(olFolderCalendar)
     
      sFilter = "[Start] = '" & Format(OutlookStartTime, "ddddd h:nn AMPM") & _
        "' And [End] = '" & Format(OutlookEndTime, "ddddd h:nn AMPM") & "' " & _
        " And [Subject] = '" & Me.ap_with_whom & " - " & Me.ap_type & "'"
     
      Set objAppointment = objAppointments.Items.Find(sFilter)
     
      If Not TypeName(objAppointment) = "Nothing" Then
        objAppointment.Delete
      End If
     
      Set objAppointment = Nothing
      Set objAppointments = Nothing
  • NeoPa
    Recognized Expert Moderator MVP
    • Oct 2006
    • 32633

    #2
    Grrrr.

    265 posts and you're still writing questions like this? You should be embarrassed. Copy/pasting a chunk of code with a short sentence explaining ???. What? It doesn't work!

    What works? What doesn't? Does it even compile? What do you see to show you it doesn't work if/when you try to run it?

    Comment

    • didacticone
      Contributor
      • Oct 2008
      • 266

      #3
      HAHAHA, OK... I wrote a quick post to start a dialog... what's up your ass dude? Apologies, I haven't grown at the programming pace you would like, no need to turn toxic about it. Asking a question on a forum intended for questions to be asked is embarrassing? Sad that you feel so entitled on a message board to talk to people like this, that's what is actually embarrassing, lol. That's the sad thing about you keyboard warriors. Get me banned or whatever you want big shot, enjoy the power, lol. Later my friend.

      Comment

      • DJRhino1175
        New Member
        • Aug 2017
        • 221

        #4
        I did build a database based on what's in the code above and had to add a reference to Microsoft outlook. Once I did that everything compiled. So I tried running the code using a Click a button, but nothing seemed to happen. When I opened outlook no new appointment was made. I hope this helps with getting this figured out for the one asking the question.

        Comment

        • NeoPa
          Recognized Expert Moderator MVP
          • Oct 2006
          • 32633

          #5
          You're 100% wrong. I was biting my tongue.

          In reality it seems clear to me that you're both lazy and entitled. Your minimalist attempt at a question wasn't just embarrassing - it was actually quite shocking. New members get away with that as it can be confusing for someone new to asking questions on a forum exactly what is expected and how best to go about doing that.

          In your case however, this is repeated behaviour, and this isn't the first time I've had to make the same point. It's not an uncommon response from those who feel thus entitled to do Sweet Fanny Adams as far as their own effort's concerned and expect others to do all the heavy lifting on their behalf, to get all upset and hard-done-by when someone, who is there purely and simply to help, has to get side-tracked into explaining that it's not even possible when those asking the questions avoid including any of the information that would be required in order to provide such help.

          You're right - almost. As administrator, and even as a moderator, I wouldn't need to get you banned as we have the power to ban you directly for a period, but that would be like using physical violence on an impertinent child. It would reflect worse on me even than on you. Be warned - I will never be so lenient when I come across such behaviour with any of my junior colleagues.

          I can't help feeling that you've rather soured your chances of getting some of our volunteer experts to make the extra effort to help you though, when you react in such an entitled way. I know that I steer well clear of such members when I see behaviour like that (Other than continuing to monitor of course).

          Comment

          Working...