电子邮件 - 如何将光标放在正文文本的末尾? [英] Email -How do I place cursor at the end of the body text?

查看:308
本文介绍了电子邮件 - 如何将光标放在正文文本的末尾?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在使用此问题的答案(即代码)使用当前的公开电子邮件建立电子邮件步骤。每次运行宏时,它会将一段正文文本添加到已打开电子邮件的正文文本中。问题是,如果我在宏运行之间手动对电子邮件进行了一些更改,那么在下一次运行时,宏将插入新的正文文本构建块,在那里我离开游标。但是我希望宏在现有(和展开)正文文本结束后始终添加新的正文文本。更具体地说,这意味着我(可能)需要在代码oSelection.InsertAfter myText(参见上面的链接中的代码)行之前的一些代码,将光标(插入点)移动到打开的电子邮件的末尾我正在处理。

I am using the answer (i.e. the code) to this question Working with current open email to build an email in steps. Every time I run the macro, it adds a piece of body text to the existing body text of an open email. The problem is that if I manually do some changes to the email between the macro "runs", then upon next run, the macro will insert the new body text building block where I left the cursor. But I want the macro to always add the new body text after the end of the existing (and expanding) body text. More specifically, this means that I (probably) need some code just before the line with the code "oSelection.InsertAfter myText" (see the code in the above link) that moves the cursor (insertion point) to the end of the open email that I am working with.

我试图玩SendKeys命令,但使用我只是将光标发送到excel工作簿表的末尾我有宏按钮。我想让游标结束打开的电子邮件!

I have tried to play around with the SendKeys-command but using that I only manage to send the cursor to the end of the excel workbook sheet where I have the macro button. I want the cursor to end of the open email instead!

推荐答案

宏在主题字段中留下光标。这将使光标向下移动到正文中,并将其移动到行尾:

The macro leaves the cursor in the subject field. This will jump cursor down into the body, and move it to the end of the line:


SendKeys{ Tab} {End},True

完整示例:

Public Sub CreateNewMessage()
Dim objMsg As MailItem


设置objMsg = Application.CreateItem(olMailItem)


与objMsg
.To =fake@example.com
.CC =other@example.com
.BCC =
.Subject =为您测试电子邮件
.Categories =
。 VotingOptions =
.BodyFormat = olFormatPlain'发送纯文本消息
.Body =感谢您的提交。
.Display
SendKeys{Tab} {End} ,True
End with


设置objMsg = Nothing
End Sub

Public Sub CreateNewMessage() Dim objMsg As MailItem Set objMsg = Application.CreateItem(olMailItem) With objMsg .To = "fake@example.com" .CC = "other@example.com" .BCC = "" .Subject = "Test email for you" .Categories = "" .VotingOptions = "" .BodyFormat = olFormatPlain ' send plain text message .Body = "Thank you for your submission. " .Display SendKeys "{Tab}{End}", True End With Set objMsg = Nothing End Sub

参考文献:

http:// ww w.slipstick.com/developer/create-a-new-message-using-vba/

这篇关于电子邮件 - 如何将光标放在正文文本的末尾?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆