Microsoft Office Forums

Go Back   Microsoft Office Forums > >

Reply
 
Thread Tools Display Modes
  #1  
Old 12-30-2015, 10:12 AM
mktate mktate is offline Userform without inserting Bookmark text Windows 10 Userform without inserting Bookmark text Office 2010 64bit
Novice
Userform without inserting Bookmark text
 
Join Date: Dec 2015
Posts: 26
mktate is on a distinguished road
Default Userform without inserting Bookmark text


I have long documents that use bookmarks/ASK/REF as the method to include repeated text. The documents also incorporate bookmarks in conjunction with IF fields to insert optional text. The text is never inserted at the bookmark locations (the bookmarks are not placed at insertion points - only "randomly" in the document since they are never used) - the text is only inserted at REF locations (or IF locations). The number of ASK fields is now so large, I would like to create a userform to do the work of the ASK fields but without having to completely "redo" the bookmark/REF/IF from the original documents. The problem is, any userform/VBA code I see inserts text from a textbox at the Bookmark location (replacing the bookmark and/or having further code to reinsert the Bookmark) rather than just providing a value for a Bookmark to then use within the document for the REF/IF fields. Could anyone help with code so that I can ask questions in the userform (with textboxes and/or other content controls, check boxes, etc.) to obtain values for the existing Bookmarks in my document, but NOT to insert at Bookmark locations. I would like to use the userform responses to assign values to the bookmarks for use in the existing fields within the document? I would use ActiveDocument.Fields.Update at the end if I can figure out the Bookmark issue. Thanks.
Reply With Quote
  #2  
Old 12-30-2015, 11:38 AM
gmaxey gmaxey is offline Userform without inserting Bookmark text Windows 7 32bit Userform without inserting Bookmark text Office 2010 (Version 14.0)
Expert
 
Join Date: May 2010
Location: Brasstown, NC
Posts: 1,429
gmaxey is a jewel in the roughgmaxey is a jewel in the roughgmaxey is a jewel in the roughgmaxey is a jewel in the rough
Default

If you don't want the text inserted at the bookmarks then where do you want it inserted?

If you are considering using content controls then why are you even bothering with bookmarks or REF fields for that matter. That is like accelerating your Ferrari with a horse whip.
__________________
Greg Maxey
Please visit my web site at http://www.gregmaxey.com/
Reply With Quote
  #3  
Old 12-30-2015, 12:19 PM
mktate mktate is offline Userform without inserting Bookmark text Windows 10 Userform without inserting Bookmark text Office 2010 64bit
Novice
Userform without inserting Bookmark text
 
Join Date: Dec 2015
Posts: 26
mktate is on a distinguished road
Default

Hi - thanks for the reply. The problem is this is an existing long document created and updated over many years - I didn't just start with the Bookmark/REF option. I am trying to get the document (and those who use it) somewhat into this century. At the time the document was created, there were only a few ASK fields, so it was easy to tab through them - only client names and dates, etc., were needed, so the Bookmark/ASK/REF worked like a charm. But, as the documents were made more complex and we started adding options, the number of fields has grown tremendously, and a user form would be easier for the us to work through than the multiple ASK dialog boxes. I am trying to not recreate the documents and remove the bookmarks and fields, if possible, assuming there would be a way to work with them rather than remove them (but maybe I am wrong and it would take more time to update rather than to work from scratch). As indicated before, the repeated text is inserted at multiple REF locations throughout the document, and the bookmark text/answers to the ASK fields are also used in nested IF fields to insert conditional text (some of them ask for a simple Y or N and then conditional text is inserted according to the responses). The text is never inserted at the location of the bookmark. The bookmarks just needed to be created for the ASK/IF fields to operate properly. Alternatively, I would like code to get all of the ASK fields from the document onto one user form if I cannot create a user form to work with the bookmarks properly. There are approximately 80 ASK boxes in each document to work through currently and multiple users who each like certain default options (these defaults have been incorporated into some ASK fields).
Reply With Quote
  #4  
Old 12-30-2015, 12:36 PM
gmaxey gmaxey is offline Userform without inserting Bookmark text Windows 7 32bit Userform without inserting Bookmark text Office 2010 (Version 14.0)
Expert
 
Join Date: May 2010
Location: Brasstown, NC
Posts: 1,429
gmaxey is a jewel in the roughgmaxey is a jewel in the roughgmaxey is a jewel in the roughgmaxey is a jewel in the rough
Default

I would start from scratch.

Repeated data can be handled with mapped content controls. Conditional text can be handled with the content control exit event or existing IF fields.

http://gregmaxey.com/word_tip_pages/..._controls.html
http://gregmaxey.com/word_tip_pages/..._userform.html
__________________
Greg Maxey
Please visit my web site at http://www.gregmaxey.com/
Reply With Quote
  #5  
Old 12-30-2015, 01:24 PM
mktate mktate is offline Userform without inserting Bookmark text Windows 10 Userform without inserting Bookmark text Office 2010 64bit
Novice
Userform without inserting Bookmark text
 
Join Date: Dec 2015
Posts: 26
mktate is on a distinguished road
Default

Thanks for your reply - it would be great to avoid that, however. I realize I "could" use content controls, etc. to redo the project from scratch, but would like to have some ideas how not to recreate everything before jumping to that as this is a complex doc and the issue is not with how to repeat the text or insert conditional text, it is only to get a user interface for multiple people without having to jump through the document. So a user form with VBA is preferable to controls that require tabbing through or the existing method with ASK fields. If there is anyone out there with any ideas for VBA that may accomplish just "setting" bookmark values without inserting into a bookmark location or placing multiple ASK fields into a dialog/userform, that is likely what is likely will get me where I need to go at this point with the time frame/cost involved.
Reply With Quote
  #6  
Old 12-30-2015, 03:32 PM
gmaxey gmaxey is offline Userform without inserting Bookmark text Windows 7 32bit Userform without inserting Bookmark text Office 2010 (Version 14.0)
Expert
 
Join Date: May 2010
Location: Brasstown, NC
Posts: 1,429
gmaxey is a jewel in the roughgmaxey is a jewel in the roughgmaxey is a jewel in the roughgmaxey is a jewel in the rough
Default

Sub ScratchMacro()
'A basic Word macro coded by Greg Maxey
Dim oBM As Bookmark
Dim oRng As Range
Set oBM = ActiveDocument.Bookmarks("A") 'this is a bookmark associated with an ASK field
Set oRng = oBM.Range
oBM.Range.Text = "This is the new value" 'or use a value set by a userform control!
ActiveDocument.Bookmarks.Add "A", oRng
lbl_Exit:
Exit Sub
End Sub
__________________
Greg Maxey
Please visit my web site at http://www.gregmaxey.com/
Reply With Quote
  #7  
Old 12-30-2015, 05:53 PM
gmaxey gmaxey is offline Userform without inserting Bookmark text Windows 7 32bit Userform without inserting Bookmark text Office 2010 (Version 14.0)
Expert
 
Join Date: May 2010
Location: Brasstown, NC
Posts: 1,429
gmaxey is a jewel in the roughgmaxey is a jewel in the roughgmaxey is a jewel in the roughgmaxey is a jewel in the rough
Default

You can set text in content controls with a userform just as easily as you can bookmarks or anything else.

However if you want to keep patching up an old unruly document that is your business. Say you have three ask fields bookmarkd name, age and IQ.

Create a userform with three text fields txtName, txtAge and txtIQ and a command button. Use this as the cb click procedure:

Code:
Private Sub CommandButton1_Click()
Dim oRng As Range
Dim oBM As Bookmark
  With ActiveDocument
    Set oBM = .Bookmarks("Name")
    Set oRng = oBM.Range
    oBM.Range.Text = txtName
    .Bookmarks.Add "Name", oRng
    Set oBM = .Bookmarks("Age")
    Set oRng = oBM.Range
    oBM.Range.Text = txtAge
    .Bookmarks.Add "Age", oRng
    Set oBM = .Bookmarks("IQ")
    Set oRng = oBM.Range
    oBM.Range.Text = txtIQ
    .Bookmarks.Add "IQ", oRng
  End With
  Hide
End Sub
__________________
Greg Maxey
Please visit my web site at http://www.gregmaxey.com/
Reply With Quote
  #8  
Old 12-31-2015, 09:20 AM
mktate mktate is offline Userform without inserting Bookmark text Windows 10 Userform without inserting Bookmark text Office 2010 64bit
Novice
Userform without inserting Bookmark text
 
Join Date: Dec 2015
Posts: 26
mktate is on a distinguished road
Default

Thanks, Greg. I really appreciate the Code to get a quick fix in place while we decide on whether I will be "unleashed" to do a more comprehensive overhaul. I used your site to get the userform set up, so thanks for all of that great information, as well.
Reply With Quote
  #9  
Old 12-31-2015, 01:11 PM
gmaxey gmaxey is offline Userform without inserting Bookmark text Windows 7 32bit Userform without inserting Bookmark text Office 2010 (Version 14.0)
Expert
 
Join Date: May 2010
Location: Brasstown, NC
Posts: 1,429
gmaxey is a jewel in the roughgmaxey is a jewel in the roughgmaxey is a jewel in the roughgmaxey is a jewel in the rough
Default

My pleasure.
__________________
Greg Maxey
Please visit my web site at http://www.gregmaxey.com/
Reply With Quote
Reply

Tags
bookmark, if fields, userform



Similar Threads
Thread Thread Starter Forum Replies Last Post
Userform without inserting Bookmark text Bookmark not replaced when inserting but to lower right corner of image newbieX Word VBA 6 11-20-2015 02:03 PM
Send Userform Text to Bookmark tddfs Word VBA 5 07-30-2015 05:55 PM
Userform without inserting Bookmark text Moving Selected Items from a Multiselect Listbox on a userform to a bookmark in Word marksm33 Word VBA 3 01-15-2015 07:55 PM
Userform without inserting Bookmark text Word 2003 - IncludeText Does Not Include Bookmark Text if in a Form Text Control skarden Word 1 12-12-2011 10:39 PM
Userform without inserting Bookmark text delete all bookmark text hklein Word VBA 4 08-10-2011 04:33 AM

Other Forums: Access Forums

All times are GMT -7. The time now is 10:49 PM.


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