Microsoft Office Forums

Go Back   Microsoft Office Forums > >

Reply
 
Thread Tools Display Modes
  #1  
Old 04-13-2015, 11:47 AM
Hdata Hdata is offline Return Name of existing Textbox Windows 7 32bit Return Name of existing Textbox Office 2010 32bit
Novice
Return Name of existing Textbox
 
Join Date: Jan 2014
Posts: 26
Hdata is on a distinguished road
Default Return Name of existing Textbox


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
Reply With Quote
  #2  
Old 04-13-2015, 09:57 PM
gmayor's Avatar
gmayor gmayor is offline Return Name of existing Textbox Windows 7 64bit Return Name of existing Textbox Office 2010 32bit
Expert
 
Join Date: Aug 2014
Posts: 4,137
gmayor has much to be proud ofgmayor has much to be proud ofgmayor has much to be proud ofgmayor has much to be proud ofgmayor has much to be proud ofgmayor has much to be proud ofgmayor has much to be proud ofgmayor has much to be proud ofgmayor has much to be proud of
Default

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
Reply With Quote
  #3  
Old 04-14-2015, 06:24 AM
Hdata Hdata is offline Return Name of existing Textbox Windows 7 32bit Return Name of existing Textbox Office 2010 32bit
Novice
Return Name of existing Textbox
 
Join Date: Jan 2014
Posts: 26
Hdata is on a distinguished road
Default Textbox names

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
Attached Files
File Type: docx TestDoc1.docx (14.7 KB, 10 views)
Reply With Quote
  #4  
Old 04-14-2015, 07:17 AM
gmaxey gmaxey is offline Return Name of existing Textbox Windows 7 32bit Return Name of existing Textbox Office 2010 (Version 14.0)
Expert
 
Join Date: May 2010
Location: Brasstown, NC
Posts: 1,598
gmaxey is just really nicegmaxey is just really nicegmaxey is just really nicegmaxey is just really nicegmaxey is just really nice
Default

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
__________________
Greg Maxey
Please visit my web site at http://www.gregmaxey.com/
Reply With Quote
  #5  
Old 04-14-2015, 09:45 AM
Hdata Hdata is offline Return Name of existing Textbox Windows 7 32bit Return Name of existing Textbox Office 2010 32bit
Novice
Return Name of existing Textbox
 
Join Date: Jan 2014
Posts: 26
Hdata is on a distinguished road
Default Change Testbox Names

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
Reply With Quote
Reply



Similar Threads
Thread Thread Starter Forum Replies Last Post
Return Name of existing Textbox Add initial right to the textbox zhshqzyc OneNote 8 01-30-2015 10:50 AM
Return Name of existing Textbox TextBox / Shape name OlivierS PowerPoint 1 10-25-2014 07:57 PM
Return Name of existing Textbox Find textbox name Hdata Word VBA 17 02-01-2014 06:50 AM
Return Name of existing Textbox Display result in textbox based on the input of another textbox scarymovie Word VBA 5 05-16-2012 07:05 PM
Textbox Template t0m46 Word 0 09-07-2010 03:38 AM

Other Forums: Access Forums

All times are GMT -7. The time now is 04:00 PM.


Powered by vBulletin® Version 3.8.11
Copyright ©2000 - 2025, vBulletin Solutions Inc.
Search Engine Optimisation provided by DragonByte SEO (Lite) - vBulletin Mods & Addons Copyright © 2025 DragonByte Technologies Ltd.
MSOfficeForums.com is not affiliated with Microsoft