【发布时间】:2019-07-30 17:56:48
【问题描述】:
我办公室的团队花费大量时间将一篇文章的第一行复制粘贴到正文中,然后粘贴到主题行中。
我找到了一个解决方案,将正文的第一行设置为主题。
问题是正文的第一行文本上方总是有两到三个空白行。
解决方案设置主题为" ".
有没有办法删除顶部的空行,或者跳过它们并将主题设置为文本的第一行?
DataNumen 的 Shirley Zhang 提供了代码。
我一直在使用的 VBA 代码:
Private WithEvents objInspectors As Outlook.Inspectors
Private Sub Application_Startup()
Set objInspectors = Outlook.Application.Inspectors
End Sub
Private Sub objInspectors_NewInspector(ByVal Inspector As Inspector)
If Inspector.CurrentItem.Class = olMail And Inspector.CurrentItem.subject = "" Then
Inspector.CurrentItem.subject = " "
End If
End Sub
Private Sub Application_ItemSend(ByVal Item As Object, Cancel As Boolean)
Dim objMail As Outlook.MailItem
Dim objMailDocument As Word.Document
Dim objMailSelection As Word.Selection
If TypeOf Item Is MailItem Then
Set objMail = Item
If Len(Trim(objMail.subject)) = 0 Then
Set objMailDocument = objMail.GetInspector.WordEditor
Set objMailSelection = objMailDocument.Application.Selection
objMailDocument.Range(0, 0).Select
objMailSelection.MoveEnd wdLine
'Take first line of body as subject
objMail.subject = objMailSelection.Text
End If
End If
End Sub
【问题讨论】:
-
我无法测试,但可以尝试在第一行之后再添加几行
objMailSelection.MoveEnd wdLine行? -
它有效,但仅在某些情况下有效。太少,主题保持空白,太多,主题行整合了正文的几行。
-
你能举几个正文第一行的例子吗-