![]() |
|
#1
|
|||
|
|||
![]() I am looking for vba code which will return the name of a textbox located on a word userform, so I can put the value of the name in another procedure. Thanks in advance Hdata |
#2
|
||||
|
||||
![]()
Write the value of the text box to a named variable, that will be available until the form is unloaded, or if you want the value after that write it to a file, the registry or a document variable in the document or the template with the userform.
If you explain what it is you are trying to do, we would be better able to help.
__________________
Graham Mayor - MS MVP (Word) (2002-2019) Visit my web site for more programming tips and ready made processes www.gmayor.com |
#3
|
|||
|
|||
![]()
I use text boxes in order to assist writing documents with updatable links. I included an attached doc showing how I use textboxes, includes a userform with cmd buttons for injecting text as links.
Thanks in advance Hdata ![]() |
#4
|
|||
|
|||
![]()
You created the userform correct? Then you should already know the text field names.
Code:
Private Sub CommandButton1_Click() 'Write to three bookmarks named bmA, bmB and bmC the content of three text 'fields txtA, txtB, txtC WriteToBookmark "bmA", txtA WriteToBookmark "bmB", txtB WriteToBookmark "bmC", txtC Unload Me lbl_Exit: Exit Sub End Sub Sub WriteToBookmark(strBMName As String, strText As String) Dim oRng As Word.Range Set oRng = ActiveDocument.Bookmarks(strBMName).Range oRng.Text = strText ActiveDocument.Bookmarks.Add strBMName, oRng lbl_Exit: Exit Sub End Sub |
#5
|
|||
|
|||
![]()
OK, Now I see your that your method would reduce the amount of code needed when changing the contents of the textbox, which is also the contents of my bookmarks. Your userform uses a single command button which also closes the userform, whereas, the other way I was using requires one procedure for each textbox and changes the text while the userform remains open.
Thanks, that works. ![]() Hdata |
![]() |
|
![]() |
||||
Thread | Thread Starter | Forum | Replies | Last Post |
![]() |
zhshqzyc | OneNote | 8 | 01-30-2015 10:50 AM |
![]() |
OlivierS | PowerPoint | 1 | 10-25-2014 07:57 PM |
![]() |
Hdata | Word VBA | 17 | 02-01-2014 06:50 AM |
![]() |
scarymovie | Word VBA | 5 | 05-16-2012 07:05 PM |
Textbox Template | t0m46 | Word | 0 | 09-07-2010 03:38 AM |