Home |
Search |
Today's Posts |
#1
|
|||
|
|||
Problem with Word Ranges
I am about my wits end trying to deal with the Range object, so hopefully someone can help me with my dilemma. I am building a project which scours a Word document for various tags. An example of a tag would be: [~ItemText~]. After the Tag is some text that the user fills in and esentially becomes the value of the tag. Example: -[~ItemText~]Why did the chicken cross the road?- What I have done in my code is move the starting and ending points of the document range to get the tag name and then the tag value. After it finds a match, it moves on, etc... This part is no problem and it works just fine. Certain tag values have to have formatting placed on them based on what the user types in. So if the user types "My name is Fred", and Fred is in Bold Text, my value has to read "My name is bFred/b. I can do formatting properly. My function does this just fine, see below for the problem. My dilemma is this though: As I pass my tag value range into my function that does the formatting, it continues to format the entire document past the Range.End mark. not just the 25 or so characters I set for the range. Here is another example to clarify: -------------------------------------------- Rng.Text="My name is Fred" Rng.Start=1 Rng.End=15 I pass the range (Rng) to the Function for formatting and I get my desired results, but it goes beyond the Rng.End and continues to format anything else that may be bolded. I only need it to format the text of the range that I send it. -------------------------------------------- I have tried using the Range.Duplicate Property, but that didn't seem to help. Perhaps I was using it incorrectly though. I have tried just passing the Rng.Text as a String and returning that, but the same results are occurring. Can anyone assist me with this issue? Thanks in advance. -- Disastor ------------------------------------------------------------------------ Disastor's Profile: http://www.msusenet.com/member.php?userid=1595 View this thread: http://www.msusenet.com/t-1870456324 |
#2
|
|||
|
|||
You have posted in a very heavily trafficked end user NG, which is not
frequented by VBA types; you would be better advised to post in one of the word.vba hierarchy of NGs. -- Suzanne S. Barnhill Microsoft MVP (Word) Words into Type Fairhope, Alabama USA Word MVP FAQ site: http://word.mvps.org Email cannot be acknowledged; please post all follow-ups to the newsgroup so all may benefit. "Disastor" wrote in message news I am about my wits end trying to deal with the Range object, so hopefully someone can help me with my dilemma. I am building a project which scours a Word document for various tags. An example of a tag would be: [~ItemText~]. After the Tag is some text that the user fills in and esentially becomes the value of the tag. Example: -[~ItemText~]Why did the chicken cross the road?- What I have done in my code is move the starting and ending points of the document range to get the tag name and then the tag value. After it finds a match, it moves on, etc... This part is no problem and it works just fine. Certain tag values have to have formatting placed on them based on what the user types in. So if the user types "My name is Fred", and Fred is in Bold Text, my value has to read "My name is bFred/b. I can do formatting properly. My function does this just fine, see below for the problem. My dilemma is this though: As I pass my tag value range into my function that does the formatting, it continues to format the entire document past the Range.End mark. not just the 25 or so characters I set for the range. Here is another example to clarify: -------------------------------------------- Rng.Text="My name is Fred" Rng.Start=1 Rng.End=15 I pass the range (Rng) to the Function for formatting and I get my desired results, but it goes beyond the Rng.End and continues to format anything else that may be bolded. I only need it to format the text of the range that I send it. -------------------------------------------- I have tried using the Range.Duplicate Property, but that didn't seem to help. Perhaps I was using it incorrectly though. I have tried just passing the Rng.Text as a String and returning that, but the same results are occurring. Can anyone assist me with this issue? Thanks in advance. -- Disastor ------------------------------------------------------------------------ Disastor's Profile: http://www.msusenet.com/member.php?userid=1595 View this thread: http://www.msusenet.com/t-1870456324 |
#3
|
|||
|
|||
Hi Disastor,
My dilemma is this though: As I pass my tag value range into my function that does the formatting, it continues to format the entire document past the Range.End mark. not just the 25 or so characters I set for the range. Here is another example to clarify: -------------------------------------------- Rng.Text="My name is Fred" Rng.Start=1 Rng.End=15 Unfortunately, you don't show use the part that does the formatting... Cindy Meister INTER-Solutions, Switzerland http://homepage.swissonline.ch/cindymeister (last update Jun 8 2004) http://www.word.mvps.org This reply is posted in the Newsgroup; please post any follow question or reply in the newsgroup and not by e-mail :-) |
Reply |
Thread Tools | |
Display Modes | |
|
|
Similar Threads | ||||
Thread | Forum | |||
Making Word do something that Wordperfect can do | New Users | |||
Word 2003 Mailmerge problem - works in Word 2000 | Mailmerge | |||
1st word in heading flush left second word flush right | New Users | |||
In Word, how can I see all files (*.*) in "save as"? | New Users | |||
letters - ask/fillin | New Users |