Set text box value in Word VBA - vba

I have a Word 2010 form template with various text boxes, combo lists and radio buttons. I wish to take the value from one text box and insert it as the value of another text box when a Save button is invoked. I have extracted the value from the source text box with the code below but how do I then insert it as the value of the target text box? I have tried a few things including the reverse of the code below but so far without success.
srp = ActiveDocument.SelectContentControlsByTag("RPI").Item(1).Range.Text

The Range.Text property is read/write. So you use the exact reversal of the code you have.
srp = ActiveDocument.SelectContentControlsByTag("RPI").Item(1).Range.Text ' Read
ActiveDocument.SelectContentControlsByTag("SRP").Item(1).Range.Text = srp ' Write

Related

How to get the Text from Text Box which is clicked, by using VBA?

I'm working on a Presentation where I have a tabular form of information, where every first column cells have text which function, and I want to get that text from the cell so that I can do something based on the Text.
Here is the function which can help me get the name of the object which is clicked.
Sub getText(oShape)
MsgBox oShape.Name
End Sub
Here is the
You'll see Text Box with text One Two Three, every word has VBA function given to it. Now what I want is when someone clicks any word, it tells which word is clicked.

Difference between Combobox properties SelText and Text?

I don't quite understand the differences between the combobox properties SelText and Text.
If I want to send the content of a combobox as a parameter to another procedure, should I send .text or .selText?
If I want to make enter text into a combobox using a macro, should I write the text in .selText or .Text?
The difference is really given in the name (SelText vs. Text) where Sel stands for Selected. One is used to return or modify the selected text (i.e. SelText) and the other is used to return or modify the entire text (i.e. Text).
If no text is selected in the ComboBox then they return and modify the same value.
I suspect you want to use Text unless you are specifically interested in the selected text.
This appears to be consistent for an ActiveX control on a Worksheet or for a control on a User Form.

Which text field should I use in word and how to fill it

I am trying to use a text field in my word template document but I confused which one should I use?!!
which one you recommend?
Rick text
Text
Text Form Field
My second question is how to address these component in Macro? I use below code:
ActiveDocument.FormFields("TextboxName")
Third question is how to set a value to this component in Macro? so many website use .Value but I don't know why I cannot find this field in above component.
Last question is: if I use any form field, a gray shadow exist below my component, how I can remove it? it is even coming in check print.:(
I am using word 2007.
You would add : textFormField.
you would pass value by Me.FormFields("Text1").Result = "abc"
in your controls tab,
somewhere next to the formField control find the "formFieldShadding"
control. when you select that control your gray shadding will
disappear.

Visual Basic read, split, modify .txt file

I'm using visual basic 2010 and im a new user. I have my project called mini database.
I want to export and display my text file in my program.
05655606515|Working|John
12345456445|Working|Alex
42348564041|Not Working|Jean
I have my 3 columns table and i want an unlimited rows. The rows and depends on how many lines are there in the text file.
The first column a text box, which i can modify what i like to enter on it.
The second column is a combo box which i can select if it is working or not.
And the third column is also a textbox which i can type the name of a user.
Please help me to have my project. Thank you stackoverflow!
Make a form with a textbox, combo box, and a second textbox.
Add a command button to save the data, one to show data, and possibly one to cancel and one to exit.
Fill the combobox with the appropriate items.
In the click handler for the save button, write the data to a file with "append".
The show data button can read the file display the text in a multiline text box or rich text box.

setting textbox text equal to textbox text on a different form?

is it possible in design mode to set the textbox text property to the text property of a textbox in a different form in vb.net?
You could use the ApplicationSettings.PropertyBinding property of the text box to accomplish what you want. If you sort the text box properties A-Z, it should be the first one in the list in parenthesis. Just create a shared application value and it will apply to each control that binds to the value.