Microsoft Office Forums

Go Back   Microsoft Office Forums > >

 
 
Thread Tools Display Modes
Prev Previous Post   Next Post Next
  #2  
Old 08-01-2021, 06:43 PM
Guessed's Avatar
Guessed Guessed is offline Generate a string only if textbox has been changed Windows 10 Generate a string only if textbox has been changed Office 2016
Expert
 
Join Date: Mar 2010
Location: Canberra/Melbourne Australia
Posts: 4,161
Guessed has a brilliant futureGuessed has a brilliant futureGuessed has a brilliant futureGuessed has a brilliant futureGuessed has a brilliant futureGuessed has a brilliant futureGuessed has a brilliant futureGuessed has a brilliant futureGuessed has a brilliant futureGuessed has a brilliant futureGuessed has a brilliant future
Default

I find working with bookmarks as anchors to be quite annoying especially when working with those bookmarks to populate text in the document from the userform. I prefer to use content controls and populate them either indirectly from linked XML or directly in code.

Staying with bookmarks, if you want to add one, you need to provide a range for it to go and close the quotes on its name. For instance, this line won't work
ActiveDocument.Bookmarks.Add Name:="bmDA

but this should
ActiveDocument.Bookmarks.Add Name:="bmDA", Range:=ActiveDocument.Paragraphs(1).Range

The act of setting the text value content of a bookmark actually removes the bookmark [see Sentence #1 above] so these lines of code put text in the document but also remove the bookmark
Set Temp = ActiveDocument.Bookmarks("bmDA").Range
Temp.Text = Me.PNBox.Value
__________________
Andrew Lockton
Chrysalis Design, Melbourne Australia
Reply With Quote
 

Thread Tools
Display Modes


Similar Threads
Thread Thread Starter Forum Replies Last Post
Generate a string only if textbox has been changed Wildcard replace any string in context with a specified string wardw Word 7 05-07-2018 09:13 AM
Generate a string only if textbox has been changed How can I compare a string in a cell to another string? Amitti Word VBA 2 04-10-2017 07:35 PM
How to find all string within string. PRA007 Word VBA 18 02-12-2016 08:11 PM
Generate a string only if textbox has been changed Way to search for a string in text file, pull out everything until another string? omahadivision Excel Programming 12 11-23-2013 12:10 PM
Generate a string only if textbox has been changed Display result in textbox based on the input of another textbox scarymovie Word VBA 5 05-16-2012 07:05 PM

Other Forums: Access Forums

All times are GMT -7. The time now is 03:30 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