Copy a Word string to use in another app.

K

Kim Jacobs

I am using the following code to combine 2 form fields and copy to the clipboard. The form is protected.

Everything works except the selection.text = strLN line. It pastes the selection to the field occupied by the cursor.

The optimum solution would be that ln2 would be highlighted and the results from ln1 and ln2 are ready to paste.

Thanks

Sub Copy_LNTest()
Dim strTemp1 As String
Dim strTemp2 As String
Dim strLN As String

strTemp1 = ActiveDocument.Bookmarks("ln1").Range.Text
strTemp2 = ActiveDocument.Bookmarks("ln2").Range.Text
strLN = strTemp1 & strTemp2

Selection.Text = strLN

Selection.Copy

End Sub



Submitted via EggHeadCafe - Software Developer Portal of Choice
HTML Horizontal Bar Chart
http://www.eggheadcafe.com/tutorial...6-3370bea2c012/html-horizontal-bar-chart.aspx
 
D

Doug Robbins - Word MVP

See the article "Manipulating the clipboard using VBA” at:

http://www.word.mvps.org/FAQs/MacrosVBA/ManipulateClipboard.htm


Dim MyData As DataObject
Dim strClip As String
strClip = ActiveDocument.FormFields("ln1").Result &
ActiveDocument.FormFields("ln2").Result
Set MyData = New DataObject
MyData.SetText strClip
MyData.PutInClipboard



--
Hope this helps.

Please reply to the newsgroup unless you wish to avail yourself of my
services on a paid consulting basis.

Doug Robbins - Word MVP, originally posted via msnews.microsoft.com

in message news:[email protected]...
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top