PDA

View Full Version : copy selected e-mail body



truszko1
06-09-2011, 08:54 AM
hey, guys!
I have created a userform that contains a TextBox1. I am adding a feature that would work like this:
select some text from the e-mial body --> hit a shortcut key --> the userform is shown --> the selected text appears in the TextBox1

I have most of the code


Sub CopySelctedText()
Dim objOL As Application
Dim objDoc As Object
Dim objSel As Object
Set objOL = Application
Set objDoc = objOL.ActiveInspector.WordEditor
Set objSel = objDoc.Windows(1).selection
UserForm1.Show
UserForm1.TextBox1.Value = objSel
end sub

But the problem is that the macro has to be run twice to work properly. Meaning, I select a text, and I need to run the macro twice before the selected text appears in the text-box. I am not sure why it is not acting as desired...?

Thanks!