#1
|
|||
|
|||
Trimming doesn’t show any difference in the ‘Watches’ value
Using the Trim function under certain circumstances doesn’t show any difference in the ‘Watches’ value or Immediate window.
Here’s an example sentence that can be copied into a document to show what I mean: A MAN AND ANOTHER IN THE HOUSE ARE GOING TO THE TOWN. And here’s a macro to use with it: Code:
Sub Macro13() For Each wrd In ActiveDocument.Words Select Case Trim(wrd) Case "A", "AND", "OF", "IN", "IS", "TO", "THE" wrd.Case = wdLowerCase End Select Next wrd End Sub It seems that “wrd” is being trimmed but it isn’t showing in the Watch list or Immediate window, which appears unusual to me. More than likely this has to do with “wrd” being listed as type “Variant/Object/Range”, whereas the Trim function (as far as I know) is only for use with strings; but I still don’t understand why, or even how, it’s being trimmed but not trimmed (as it seems) at the same time. Anyone? |
#2
|
||||
|
||||
This is VBA we are talking about here. Perhaps other programming languages change the value of a variable just by asking for a characteristic of that variable's value but it doesn't happen in VBA.
The value of the variable 'wrd' is not being changed by your line Select Case Trim(wrd) If you want to change the value of the text in wrd then you need to tell it to change eg wrd = Trim(wrd)
__________________
Andrew Lockton Chrysalis Design, Melbourne Australia |
#3
|
|||
|
|||
Thanks Andrew for your prompt reply.
|
|
Similar Threads | ||||
Thread | Thread Starter | Forum | Replies | Last Post |
Difference between 16:9 Widescreen and 16:9 On-Screen Show? | presenterrick | PowerPoint | 3 | 06-22-2018 08:19 AM |
OneDrive version doesn't show up on desktop | derohanes | Excel | 0 | 06-04-2018 10:15 AM |
New Master doesn't show up in my layout options | LadyBug679 | PowerPoint | 0 | 02-17-2017 10:44 AM |
24 hour task calendar doesn't show a day?? | benl | Project | 3 | 12-31-2015 02:55 PM |
trimming excess image data in Word document | gib65 | Word | 2 | 12-13-2011 07:50 AM |