ForEachLoop는
귀하의 질문에 크게 응답 한 것으로 보인다. 나는 명확성을 위해 약간의 정보를 추가하고이 질문에 답을 제공하기 만 할 것입니다. Microsoft 포럼 (Ossiemac) 사용자는 Siddarth Rout에서 설명한대로 LateBinding was the way to go을 기록했습니다. Siddarth에 의해 암시 된 것처럼, 그것은 당신이 참조에 대해 걱정할 필요가 없다는 것을 의미합니다. -
~ JOL
Private Sub btnLateBindMethod_Click()
' Variables used for LateBinding
Dim objOutlook As Object 'Outlook.Application
Dim objEmail As Object 'Outlook.MailItem
Dim objNameSpace As Object 'Outlook.NameSpace
Const OutLookMailItem As Long = 0 'For Late Binding
Const OutLookFolderInbox As Long = 6 'For Late Binding
Const OutLookFormatHTML As Long = 2 'For Late Binding
Dim strSubject As String
Dim strAddress As String
On Error Resume Next
Set objOutlook = GetObject(, "Outlook.Application")
On Error GoTo 0
If objOutlook Is Nothing Then
Set objOutlook = CreateObject("Outlook.Application")
Set objNameSpace = objOutlook.GetNamespace("MAPI")
objNameSpace.GetDefaultFolder(OutLookFolderInbox).Display
End If
Set objEmail = objOutlook.CreateItem(OutLookMailItem)
strSubject = "Hello World"
With objEmail
'.To = strToAddress 'Commented to prevent accidental send
.Subject = strSubject
.BodyFormat = OutLookFormatHTML
.Display
'Full Name of window can change depending on Tools -> Options -> Mail Format
'Changing this option for outgoing mail changes the window name.
'However, AppActivate appears not to require entire name but needs up to end
'of - Message which is included in heading following the Subject string
'irrespective of the Mail Format option chosen.
AppActivate (strSubject & " - Message")
End With
End Sub
지미 페냐는 contrast of EarlyBinding and LateBinding 토론 글이 있습니다
Ossiemac는 내가 다시 포맷하고 여기에 놓여있다있는 이메일의 전송에 LateBinding를 사용하기위한 몇 가지 샘플 코드를 제공
'EarlyBinding'을 사용하고 있다고 생각합니다.'LateBinding (LB) '을 사용해 보셨습니까? LB의 이점은 다른 컴퓨터에서 실행되는 다른 버전에 대해 걱정할 필요가 없다는 것입니다. 코드는 항상 코드가 실행되는 PC에있는 버전과 바인딩됩니다. 그의 링크를 참조하십시오 : http://support.microsoft.com/kb/245115 –
고마워요. 나는 그 옵션을 예비로 지키고있다. 오히려 다른 두 참조가 어느 방향 으로든 자동으로 업데이트되지만 Outlook은 특별히 그렇지 않은지 묻습니다. 그게 그런 식이면 늦은 바인딩을 사용해야합니다. – ForEachLoop
Excel VBA를 사용하여 동일한 문제가 발생했습니다. 또한 Microsoft Office 및 Microsoft Excel 라이브러리에 대한 (초기 바인딩) 참조는 버전 12와 14 사이에서 자동으로 전환되지만 Microsoft Outlook에 대한 참조는 자동으로 변경된다는 점도 유의하십시오. 즉, 12에서 14로 자동 변경되지만 결코 12로 되돌아 가지 않습니다. – comecme