我有以下宏;
# Group data by when and site
grouped_df2<-group_by(df2,when,site)
#summarise grouped data and calculate mean and standard error using function mean and std.error
summarised_df2<-summarise_each(grouped_df2,funs(mean=mean,std_error=std.error))
# Define the top and bottom of the errorbars
limits <- aes(ymax = mean + std_error, ymin=mean-std_error)
#Begin your ggplot
#Here we are plotting site vs mean and filling by another factor variable when
g<-ggplot(summarised_df2,aes(site,mean,fill=when))
#Creating bar to show the factor variable position_dodge
#ensures side by side creation of factor bars
g<-g+geom_bar(stat = "identity",position = position_dodge())
#creation of error bar
g<-g+geom_errorbar(limits,width=0.25,position = position_dodge(width = 0.9))
#print graph
g
上周这个工作得很好。现在,当宏运行时,我得到一个&#34;运行时错误-2147221241(80040107)操作失败&#34;
查看调试器失败;
Private WithEvents MySents As Outlook.Items
Private Sub Application_Startup()
Set MySents = Session.GetDefaultFolder(olFolderSentMail).Items
End Sub
Private Sub MySents_ItemAdd(ByVal Item As Object)
Dim objNS As Outlook.NameSpace
Dim targetFolder As Outlook.MAPIFolder
Set objNS = Outlook.GetNamespace("MAPI")
If TypeOf Item Is Outlook.MailItem Then
If Item.SenderName = "Sender 1" Then
Set targetFolder = objNS.Folders("Folder 1").Folders("Sent Items")
Set newItem = Item.Copy
newItem.Move targetFolder
End If
If Item.SenderName = "Sender 2" Then
Set targetFolder = objNS.Folders("Folder 2").Folders("Sent Items")
Set newItem = Item.Copy
newItem.Move targetFolder
End If
End If
End Sub
如果我看一下监视窗口中的项目,大多数属性都有&#34;操作失败&#34;在价值观中。
最奇怪的是,邮件仍然会被复制。
任何人都能看到我正在做的傻事吗?
答案 0 :(得分:-1)
SenderName属性返回一个String,指示Outlook项目的发件人的显示名称。它是在邮件项目发送后设置的。新项目(未发送)没有设置此属性。
您可以考虑使用SaveSentMessageFolder属性,该属性允许设置一个Folder对象,该对象表示发送后将保存电子邮件副本的文件夹。例如,您可以处理ItemSend事件,您可以在其中设置此属性。
Sub SetSentFolder()
Dim myItem As Outlook.MailITem
Dim myResponse As Outlook.MailITem
Dim mpfInbox As Outlook.Folder
Dim mpf As Outlook.Folder
Set mpfInbox = Application.Session.GetDefaultFolder(olFolderInbox)
Set mpf = mpfInbox.Folders.Add("SaveMyPersonalItems")
Set myItem = Application.ActiveInspector.CurrentItem
Set myResponse = myItem.Reply
myResponse.Display
myResponse.To = "Eugene Astafiev"
Set myResponse.SaveSentMessageFolder = mpf
myResponse.Send
End Sub