none
VB code works in Outlook 2010, but not in Outlook 2013

    Question

  • Hello,

    I'm using the following code on a custom form to create a new record in a different public folder containing specific information when a command button is pressed.  The code has worked fine in Outlook 2010, but it causing Outlook to stop working when used in Outlook 2013. I'm not quite sure what changed, but any recommendations to revised the code would be helpful.  Thanks in advance.  Dave

    Sub CLUpdate_Click()

          Dim TempCL

          Dim myOLApp

          Dim myNS

          Dim objfolder

          Dim newtitem

          Dim conname

          Dim constudentid

          Dim conprogram

          Dim consubprogram

          Dim consubmajor

          Dim concldate

          Dim concltime

          Dim conclinitials

          Dim conreason

          Dim condisposition

          Dim connotes

         

          Set TempCL = Item.UserProperties.Find("CallLog")

          Set conname = Item.UserProperties.Find("StudentName")

          Set constudentid = Item.UserProperties.Find("StudentID")

          Set conprogram = Item.UserProperties.Find("Program")

          Set consubprogram = Item.UserProperties.Find("Subprogram")

          Set consubmajor = Item.UserProperties.Find("Major")

          Set concldate = Item.UserProperties.Find("CLDate")

          Set concltime = Item.UserProperties.Find("CLTime")

          Set conclinitials = Item.UserProperties.Find("CLInit")

          Set conreason = Item.UserProperties.Find("CLReason")

          Set condisposition = Item.UserProperties.Find("CLDisposition")

          Set connotes = Item.UserProperties.Find("CLComment")

          Set myOLApp = CreateObject ("Outlook.Application")

          Set myNS = myOLApp.GetNamespace("MAPI")

          Set objfolder = myNS.GetFolderFromID("0000 <entry ID shortened for forum> FA830000")

          Set newtitem = objfolder.items.add()

          With newtitem

                .FullName = conname

                .Account = constudentid

                .CompanyName = conprogram

                .Department = consubprogram

                .Officelocation = consubmajor

                .User1 = DateValue(concldate)

                .JobTitle = concltime

                .AssistantName = conclinitials

                .Profession = conreason

                .ManagerName = condisposition

                .Body = connotes

          End With

          newtitem.Save

    Item.UserProperties.Find("CallLog") = Item.UserProperties.Find("CLSubmit")&TempCL

          Item.UserProperties.Find("CLDate") = Now()

          Item.UserProperties.Find("CLInit") = ""

          Item.UserProperties.Find("CLTime") = ""

          Item.UserProperties.Find("CLDisposition") = ""

          Item.UserProperties.Find("CLReason") = ""

          Item.UserProperties.Find("CLComment") = ""

          Item.UserProperties.Find("CLBypass") = ""

          Set conname = Nothing

          Set constudentid = Nothing

          Set conprogram = Nothing

          Set consubprogram = Nothing

          Set consubmajor = Nothing

          Set concldate = Nothing

          Set concltime = Nothing

          Set conclinitials = Nothing

          Set conreason = Nothing

          Set condisposition = Nothing

          Set connotes = Nothing

    End Sub

    Tuesday, March 28, 2017 3:54 PM

All replies

  • Hi Schraps,

    >> The code has worked fine in Outlook 2010, but it causing Outlook to stop working when used in Outlook 2013.

    Would you please clarify what you mean by "causing Outlook to stop working"?
    Is there any error message when the problem occurs?
    Have you tried testing on another computer and check if the issue persists?

    Any findings, please feel free to post back.

    Best regards,
    Yuki Sun


    Please remember to mark the replies as answers if they helped.

    If you have feedback for TechNet Subscriber Support, contact tnmff@microsoft.com.


    Wednesday, March 29, 2017 3:03 AM
    Moderator