Forums
New posts
Search forums
Members
Current visitors
Log in
Register
What's new
Search
Search
Search titles only
By:
New posts
Search forums
Menu
Log in
Register
Install the app
Install
Forums
Archive
Newsgroup Archive
Word Newsgroups
Word VBA Beginners
How can I just change the text background colour using VBA?
JavaScript is disabled. For a better experience, please enable JavaScript in your browser before proceeding.
Reply to thread
Message
[QUOTE="Blackberry, post: 5795800"] Apologies Jean-Guy I didn't want to be too wordy in case it frightened people away. Yes, I keep an ongoing count of the paragraphs used in each cell so Paragraphs(2) is actually shown as Paragraphs(intLine) in my code. I have done a msgbox what is my range.text value and it did show a funny square at the end of the text. Sounds like this is my issue how can I omit the marker from my formatting?? Thanks Blackberry was telling us: Blackberry nous racontait que : Please, next time paint a full picture, it will be easier for all involved! I guessed from looking at your code that you are actually dynamically inserting paragraphs in your table and formatting them as you go along. Now, the line Set oDoc = oNewDoc.Tables(1).Cell(intRow, intCol).Range.Paragraphs(2) is probably used after you have inserted the first name. Before it gets executed, I guess that the content of the cell is: |------------------| | BilboBaggins¶ | |¤ | |------------------| If that is the case, it means that when the line above gets executed, it sets oDoc to the cell marker (¤). So, when you next execute oDoc.Range.Text = arrPupilData(0, intCurrentRec) to insert the Freddie Boggs paragraph, the cell marker cannot be replaced by that text as a cell marker cannot be deleted. In effect, that line inserts the paragraph before the cell marker, but oDoc still points to the cell marker. Finally, when you get into With oDoc.Range oDoc points to the cell marker, which means that all the subsequent changes are applied to the cell marker, i.e. the whole cell. What is oDoc.Range when it gets executed? Have you debugged the code to see what is happening? When dealing with cells and VBA, you have to be aware that the cell marker maybe part of a range or selection. A cell marker is counted as a paragraph, but it is very different from other paragraphs (It cannot be deleted, if you format it, you format the whole cell, etc.). Make sure that your code does not include the cell marker, unless this is what you want. -- Salut! _______________________________________ Jean-Guy Marcil - Word MVP [email]jmarcilREMOVE@CAPSsympatico.caTHISTOO[/email] Word MVP site: [URL]http://www.word.mvps.org[/URL] [/QUOTE]
Verification
Post reply
Forums
Archive
Newsgroup Archive
Word Newsgroups
Word VBA Beginners
How can I just change the text background colour using VBA?
Top