2014-03-25 12 views
1

Access 2010의 일정 약속을 Outlook 공용 일정에 추가하려고합니다. 이 작업을 수행 할 수있는 여러 가지 방법을 찾았지만 내 코드와 함께 작동시키지 못하는 것 같습니다. 문제가 될 수있는 한가지는 저장할 폴더를 설정할 때 코드가하는 일을 이해하지 못한다는 것입니다. 내 Outlook 일정에 저장하는 코드는 다음과 같습니다. janettest라는 공용 Outlook 일정에 저장하려면 어떻게합니까? 그것이 내가 혼란스러워하는 곳이기 때문에 코드를 설명하십시오. 미리 감사드립니다.Access 2010에서 공용 폴더에 Outlook 일정 항목 추가

Private Sub Command60_Click() 

' Exit the procedure if appointment has been added to Outlook. 
If Me.chkAddedToOutlook = True Then 
    MsgBox "This appointment has already added to Microsoft Outlook.", vbCritical 
    Exit Sub 
Else 

    ' Use late binding to avoid the "Reference" issue 
    Dim olApp As Object  'Outlook.Application 
    Dim olAppt As Object  'olAppointmentItem 
    Dim dteTempEnd As Date 
    Dim dteStartDate As Date 
    Dim dteEndDate As Date 

    If isAppThere("Outlook.Application") = False Then 
     ' Outlook is not open, create a new instance 
     Set olApp = CreateObject("Outlook.Application") 
     Else 
     ' Outlook is already open--use this method 
     Set olApp = GetObject(, "Outlook.Application") 

    End If 

    Set olAppt = olApp.CreateItem(1) ' 1 = olAppointmentItem 

    With olAppt 

     If Nz(Me.AllDay_YesNo) = True Then 

      .Alldayevent = True 

      ' Get the Start and the End Dates 
      dteStartDate = CDate(FormatDateTime(Me.TxtBeginDate, vbShortDate)) ' Begining Date 
      dteTempEnd = CDate(FormatDateTime(Me.txtEndDate, vbShortDate))  ' End Date 
      ' Add one day to dteEndDate so Outlook will set the number of days correctly 
      dteEndDate = DateSerial(Year(dteTempEnd + 1), Month(dteTempEnd + 1), Day(dteTempEnd + 1)) 

      .Start = dteStartDate 
      .End = dteEndDate 

     Else 

      .Alldayevent = False 

      If (Me.TxtBeginDate = Me.txtEndDate) Then 

       ' Set the Start Property Value 
       .Start = CDate(FormatDateTime(Me.TxtBeginDate, vbShortDate) _ 
        & " " & FormatDateTime(Me.txtStartTime, vbShortTime)) 

       ' Set the End Property Value 
       .End = CDate(FormatDateTime(Me.txtEndDate, vbShortDate) _ 
        & " " & FormatDateTime(Me.txtEndTime, vbShortTime)) 

      Else 

       ' Get the Start and the End Dates 
       dteStartDate = CDate(FormatDateTime(Me.TxtBeginDate, vbShortDate))  
       dteEndDate = CDate(FormatDateTime(Me.txtEndDate, vbShortDate))  

       ' Add one day to dteEndDate so Outlook will set the number of days correctly 
       .Start = dteStartDate 
       .End = dteEndDate + 1 

      End If 
     End If 

     If Len(Me.Employee & vbNullString) > 0 Then 
      Dim vname, vname2, vdesc As String 
      vname = DLookup("FirstName", "tblEmployees", "EmployeeID = " & Me.Employee) 
      vname2 = DLookup("LastName", "tblEmployees", "EmployeeID = " & Me.Employee) 
      vdesc = DLookup("Description", "tblCodesWork", "WorkCodeID = " & Me.WorkCode) 
      .Subject = vname & " " & vname2 & " - " & vdesc 

     End If 

     ' Save the Appointment Item Properties 
     .Save 

    End With 

    ' Set chkAddedToOutlook to checked 
    Me.chkAddedToOutlook = True 

    ' Inform the user 
    MsgBox "New Outlook Appointment Has Been Added!", vbInformation 
End If 

ExitHere : '출시 메모리 설정 olAppt = 아무것도 설정 olApp = 아무것도 종료 하위

ErrHandle : 있는 MsgBox "오류"& 오지 Err.Number & vbCrLf & 프로그램 Err.Description _ & vbCrLf & "Module Module1의 btnAddApptToOutlook_Click 프로 시저에서" Exit Resere Exit

최종 하위

답변