Cut and paste contents of combo box to non word program

G

Guest

I have created a combo box in a word template. The combo box functionality
seems to be working well. What I need to be able to do is cut and paste from
this form. When I do, the answers chosen in the combo box do not appear (for
example in notepad .txt).

What I need to do is have a combo box that allows a user to choose a choice
or just type text in that box. The user then needs to be able to cut and
paste parts of this form into a non word program (for example notepad). I
have not used VBA before and have simply used the following:

Private Sub Document_New()

Dim vColor, vColors
vColors = Array(" ", "green", "yellow", "red")


For Each vColor In vColors
ComboBox1.AddItem vColor
Next
ComboBox1.ListIndex = 0

End Sub

Before the combo box it says: Your favorite color is:

When I cut and paste I don't get "Your favorite color is green" but just
"Your favorite color is "

Please advise.
 
C

Cindy M -WordMVP-

Hi =?Utf-8?B?bW9ydGFsa3Jpcw==?=,

the problem is that you're using an ActiveX control. This is an OLE object,
which means Word considers it to be a graphical object. The text typed into the
ComboBox is not "seen" by Word - it just "shines through" the window to the
application "behind" the ActiveX control. If you were to copy/paste this into
Word (and probably Excel) the ActiveX control would come along. When you try to
paste into something like notepad, since Notepad doesn't support ActiveX
controls, it can't be pasted (it's dropped during the paste).

In order to do this, you'd need to use code to perform the copy. Say, the user
selects some text, then clicks a button. Your code picks up all the regular
text, puts it in a string. It checks for ActiveX controls in the selection and
if it finds them, extracts their content and adds it to the string. This string
is then put on the Clipboard, so the user can paste it elsewhere.
I have created a combo box in a word template. The combo box functionality
seems to be working well. What I need to be able to do is cut and paste from
this form. When I do, the answers chosen in the combo box do not appear (for
example in notepad .txt).

What I need to do is have a combo box that allows a user to choose a choice
or just type text in that box. The user then needs to be able to cut and
paste parts of this form into a non word program (for example notepad). I
have not used VBA before and have simply used the following:

Private Sub Document_New()

Dim vColor, vColors
vColors = Array(" ", "green", "yellow", "red")


For Each vColor In vColors
ComboBox1.AddItem vColor
Next
ComboBox1.ListIndex = 0

End Sub

Before the combo box it says: Your favorite color is:

When I cut and paste I don't get "Your favorite color is green" but just
"Your favorite color is "

Cindy Meister
INTER-Solutions, Switzerland
http://homepage.swissonline.ch/cindymeister (last update Jun 8 2004)
http://www.word.mvps.org

This reply is posted in the Newsgroup; please post any follow question or reply
in the newsgroup and not by e-mail :)
 

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