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
See Question&Answers more detail:
os 与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…