2017-03-02 19 views
0

私の主な問題getexchangeuserオブジェクトにactivecellvalueをスローして、特定のユーザのスーパバイザを取得するにはどうすればよいですか??私は以下のコードを試していますが、その方法はわかりませんが、エラー91のオブジェクト変数が設定されていません。Excel VBA Getexchangeuser.Getexchangeusermanagerクエリ

Set Usersupervisor = myExchangeuser.GetExchangeUser(ActiveCell.Cells(1, 10)).GetExchangeUserManager.Alias 

私は自分の上司が必要な場合は、作品ものの、このコード行。

.To = outlookmail.Session.CurrentUser.AddressEntry.GetExchangeUser.GetExchangeUserManager.Alias 

は基本的に私は、Outlookで解決しない受信者のエイリアスまたはユーザー名を持っています。特定のエイリアスのマネージャ情報を参照して、.Toフィールドに使用する必要があります。それも可能ですか?ガイドのほとんどは私の要求に合っていません。

Dim outlookapp As Outlook.Application 
Dim outlookmail As Outlook.MailItem 
Dim myusername As String 
Dim myExchangeuser As Outlook.ExchangeUser 
Dim mngname As Outlook.AddressEntry 
Dim mysupervisor As String 

myusername = Environ("Username") 

mysupervisor = CStr(myExchangeuser.GetExchangeUser(ActiveCell.Cells(1, 10)).GetExchangeUserManager.Alias) 


Set outlookapp = New Outlook.Application 

Set outlookmail = outlookapp.CreateItemFromTemplate("C:\Users\" & myusername & "\AppData\Roaming\Microsoft\Templates\x.oft") 

With outlookmail 



'.To = ActiveCell.Cells(1, 10) 
'.To = outlookmail.Session.CurrentUser.AddressEntry.GetExchangeUser.GetExchangeUserManager.Alias 
.To = mysupervisor 

End With 

ActiveCell.Cells(1, 13) = "Yes" 
ActiveCell.Cells(1, 14) = DateTime.Now 
outlookmail.Display 

答えて

0

ok私はそれを機能させました。正確ではありませんが、構文のフォーマットを取得するのに使用できる多数の記事のおかげで、スタックオーバーフローありがとう:

Set olns = GetNamespace("MAPI") 
Set myrecipient = olns.CreateRecipient(PMstring) 
myrecipient.Resolve 
PMentry = myrecipient.AddressEntry.GetExchangeUser.GetExchangeUserManager.Alias 



With outlookmail 

.To = PMentry