按正常顺序将剪贴板粘贴在Outlook电子邮件中 [英] Paste clipboard in outlook email in normal order

查看:403
本文介绍了按正常顺序将剪贴板粘贴在Outlook电子邮件中的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有5个电子邮件用户表单。工作流程如下所示:

 创建新电子邮件

userform1.show
用户选择字段
自动打印屏幕插入文本

userform2.show
用户选择字段
自动打印屏幕插入文本

userform3.show
用户选择字段
自动打印屏幕插入文本

userform4.show
用户选择字段
自动打印屏幕已插入在文本

userform5.show
用户选择字段
自动打印屏幕插入文本

我的问题是,最后,电子邮件将如下所示:

  userform1选定字段
userform2选定字段
userform3选定字段
userform4选定字段
userform5选定字段

打印屏幕5
打印屏幕4
打印屏幕3
打印屏幕2
打印屏幕1

有没有办法使打印屏幕以正确的顺序显示?



以下是第一个用户窗体复制剪贴板的代码(打印屏幕来自另一个应用程序)



<$对象



$ b设置olInsp = .GetInspector
设置wdDoc = olInsp.WordEditor
设置oRng = wdDoc.Range
oRng.collapse 1
objItem.Display
objItem.Visible = True
objItem.HtmlBody =< br>< br> &安培; objItem.HtmlBody

错误恢复下一步
oRng.Paste

objItem.HtmlBody =< br> &安培; objItem.HtmlBody

Dim myOutlook As Object
设置myOutlook = GetObject(,Outlook.Application)
myOutlook.ActiveExplorer.Activate

结束于

我将光标移动到邮件的末尾,但粘贴不起作用

  Dim objCurrentMail As Outlook.MailItem 
Dim objWordDocument As Word.Document
Dim objWordRange As Word.Range
Dim VarPosition As Variant

'只有当前电子邮件使用单词编辑器才能工作
设置objCurrentMail = Outlook.Application.ActiveInspector.CurrentItem
设置objWordDocument = objCurrentMail。 GetInspector.WordEditor


VarPosition = objWordDocument.Range.End - 1000
设置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


解决方案

这里有代码将光标移动到最后 http://www.vboffice.net/en/developers/determine-cursor-position/

  Public Sub SetCursor()
Dim Ins As Outlook.Inspector
Dim Doc As Word.Document
Dim range As Word.range
Dim pos As Long

Set Ins = Application.ActiveInspector
设置Doc = Ins.WordEditor
如果没有文档没有了
pos = Doc.range.End - 1
设置范围= Doc.range(pos,pos)
range.Select
End If
End Sub

您的代码可能如下所示:

  Option Explici t 

Sub pasteAtEnd()

Dim olInsp As Object
Dim oRng As Object
Dim wdDoc As Object

Dim pos As Long
Dim objItem As Object

设置objItem = ActiveInspector.currentItem

带objItem

设置olInsp = .GetInspector
设置wdDoc = olInsp.WordEditor
设置oRng = wdDoc.range

objItem.Display
'objItem.HTMLBody =< br>< br> &安培; objItem.HTMLBody
objItem.HTMLBody = objItem.HTMLBody& <峰; br><峰; br> 中

pos = wdDoc.range.End - 1
设置oRng = wdDoc.range(pos,pos)
oRng.Select

MsgBoxCursor应该在邮件结尾。

'On Error Resume Next'使用正确的错误处理
oRng.Paste

结束

End Sub


I have 5 userforms for an email. The workflow goes like this:

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

My problem is that in the end, the email will look like this:

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

Is there a way to make the print screens appear in the correct order?

Here is the code that copies the clipboard for the first userform ( the print screen is from another application )

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

I made the cursor to move to the end of the mail but the paste doesn't work at all

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

解决方案

There is code here to move the cursor to the end http://www.vboffice.net/en/developers/determine-cursor-position/

Public Sub SetCursor()
    Dim Ins As Outlook.Inspector
    Dim Doc As Word.Document
    Dim range As Word.range
    Dim pos As Long

    Set Ins = Application.ActiveInspector
    Set Doc = Ins.WordEditor
    If Not Doc Is Nothing Then
        pos = Doc.range.End - 1
        Set range = Doc.range(pos, pos)
        range.Select
    End If
End Sub

Your code could look like this:

Option Explicit

Sub pasteAtEnd()

Dim olInsp As Object
Dim oRng As Object
Dim wdDoc As Object

Dim pos As Long
Dim objItem As Object

Set objItem = ActiveInspector.currentItem

With objItem

    Set olInsp = .GetInspector
    Set wdDoc = olInsp.WordEditor
    Set oRng = wdDoc.range

    objItem.Display
    'objItem.HTMLBody = "<br><br>" & objItem.HTMLBody
    objItem.HTMLBody = objItem.HTMLBody & "<br><br>"

    pos = wdDoc.range.End - 1
    Set oRng = wdDoc.range(pos, pos)
    oRng.Select

    MsgBox "Cursor should be at end of the mail body."

    'On Error Resume Next ' Use proper error handling
    oRng.Paste

End With

End Sub

这篇关于按正常顺序将剪贴板粘贴在Outlook电子邮件中的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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