我有5个用户表单用于发送电子邮件。工作流程如下:
create new email
userform1.show
user selects the fields
automatic printscreen is inserted in the text
userform2.show
user selects the fields
automatic printscreen is inserted in the text
userform3.show
user selects the fields
automatic printscreen is inserted in the text
userform4.show
user selects the fields
automatic printscreen is inserted in the text
userform5.show
user selects the fields
automatic printscreen is inserted in the text
我的问题是最终的邮件会看起来像这样:
userform1 selected fields
userform2 selected fields
userform3 selected fields
userform4 selected fields
userform5 selected fields
print screen 5
print screen 4
print screen 3
print screen 2
print screen 1
有没有办法让打印屏幕以正确的顺序出现?
这是复制第一个用户窗体的剪贴板的代码(打印屏幕来自另一个应用程序)
Dim olInsp As Object
Dim oRng As Object
Dim wdDoc As Object
With objItem
Set olInsp = .GetInspector
Set wdDoc = olInsp.WordEditor
Set oRng = wdDoc.Range
oRng.collapse 1
objItem.Display
objItem.Visible = True
objItem.HtmlBody = "<br><br>" & objItem.HtmlBody
On Error Resume Next
oRng.Paste
objItem.HtmlBody = "<br>" & objItem.HtmlBody
Dim myOutlook As Object
Set myOutlook = GetObject(, "Outlook.Application")
myOutlook.ActiveExplorer.Activate
End With
我让光标移动到邮件的末尾,但粘贴根本无效。
Dim objCurrentMail As Outlook.MailItem
Dim objWordDocument As Word.Document
Dim objWordRange As Word.Range
Dim VarPosition As Variant
'Only work if the current email is using word editor
Set objCurrentMail = Outlook.Application.ActiveInspector.CurrentItem
Set objWordDocument = objCurrentMail.GetInspector.WordEditor
VarPosition = objWordDocument.Range.End - 1000
Set objWordRange = objWordDocument.Range(VarPosition, VarPosition)
objWordRange.Select
keybd_event VK_DOWN, 0, 0, 0
keybd_event VK_DOWN, 0, KEYEVENTF_KEYUP, 0
keybd_event VK_CONTROL, 0, 0, 0
keybd_event VK_V, 0, 0, 0
keybd_event VK_CONTROL, 0, KEYEVENTF_KEYUP, 0
keybd_event VK_V, 0, KEYEVENTF_KEYUP, 0
oRng.collapse 1
将选择移动到 oRng 的开头吗?Const wdCollapseStart = 1
,Const wdCollapseEnd = 0
-- 我会先尝试使用wdCollapseEnd
。 - Andre