Help - Search - Members - Calendar
Full Version: Need a small tweek to the "add The" macro
Productivity Talk > Shortcut/Abbreviation systems and Macros > MS Word Macros
AnitaInIndy
Hi Ed or Erika! I have several versions of this macro; however, I need a small adjustment in where the cursor is to enact the macro.

Currently, the cursor is to be 1 space after the preceeding period, which also puts it 1 space ahead of the word that presently starts the sentence. Sometimes I need to do this to the first sentence in a paragraph where there is no space/period before the word. I have to add a space and then run the macro in this situation. Also, my Ctrl+right always puts my cursor immediately before a word, so I usually also have to move left 1 space to get the cursor to the right position to run these macros.

I am wondering what change might need to be made to this macro to give the same effect with the cursor immediately at the front of the word that will be lowercased. Is this an easy problem to solve? Also, I am trying to understand more about how these macros work, so could you give me the edits rather than rewrite the whole macro? Thanks for any help!!!!
Ed Weber
Anita,

I am heavily involved in two major programming projects and I will get to this when I have time. Meanwhile, perhaps Erika can handle your request.


Ed
AnitaInIndy
Thanks Ed!!! I understand completely!!
Ed Weber
Anita,

Both projects are now out for testing. If I understand what you want, you do not need a macro. With the cursor immediately to the right of the word, press Shift + F3 until the case of the word is what you want. Shift + F3, cycles through several case arrangements so you might have to press it more than once.
AnitaInIndy
Thanks for replying Ed! I do need more than that. This would be a change to a current macro. At present, my cursor has to be one space to the right of the preceding period when adding "The" before a word:
change "...blah blah. Patient..." to "...blah blah. The patient..." Your (and Erika's) macro adds "The" and lowercases the next word. I have made copies that add She, He, I, etc. as well. The problem occurs when the word is the first in a new paragraph, in which case I have to add a space before the macro will work. The other problem is that my CTRL+right to skip through words always places the cursor before the next word (rather than at the end), so I also need to move left a space to run this macro if I need it where there is no period.

What I am looking for is the language to change to enact this macro with the cursor immediately in front of the word to be lowercased, and then I will be able to add a space after the new word to be added to start the sentence. I hope this makes more sense for you!! Thanks again for your help!
Ed Weber
QUOTE (AnitaInIndy @ May 10 2010, 12:56 PM) *
I hope this makes more sense for you!!


It doesn't. I am trying to connect the code you referenced with your written request and I have been unsuccessful. Please give a more detailed example.

For your secod request, this code will act like Ctrl + Right except that the cursor will be at the last non-space character in the word. MSWord defines a "word" as the text and the space following the word. You could assign Ctrl + Right as the shortcut to this macro but this would disable the way Word does Ctrl + Right. I suggest that you assign Alt + Right. Alt + Right is already asssigned to something else but it is something that you might not be likely to use.
CODE
Sub NewMoveRIght()
'by Ed Weber
'Works like Ctrl + Right but moves to the end of the word, not to the space after the word.
With Selection
  .End = .End + 1
  If .Range.Text = " " Then .Start = .End
  .MoveRight unit:=wdWord, Extend:=wdExtend
  If Right(.Range.Text, 1) = " " Then .End = .End - 1
  .Collapse wdCollapseEnd
End With
End Sub
AnitaInIndy
Well, so sorry! As usual, I am having trouble describing the problem. Let me start with the description at the top of the macro I am talking about:
Sub AddTheLowercaseNext()
'original macro by Ed Weber Copyright © 2009 all rights reserved, slightly mangled by Erika Stimac
'Place the cursor immediately to the right of the period at the end of the last sentence. Run the macro
'<space><uppercase> will be replaced with <The><space><lowercase

What the macro does is perfect. What I want to change is where you start it from. I want to place the cursor to the immediate left of the first word in the sentence which is about to be lowercased after "The" is added (not adjacent to the preceding punctuation with spaces between). In the following example, I am using | as the cursor:

The way the macro is now:
difficulty breathing, or belly pain.| Remainder of review of systems...
(enact the macro to get: difficulty breathing, or belly pain. The remainder of review of systems) Note the cursor position.

What I need:
difficulty breathing, or belly pain. |The remainder of review of systems...
(enact the macro to get same as above, but with the cursor starting in this position
I added extra spaces to emphasize where the cursor should be to enact. I am so sorry if this is confusing or unclear. It is really a minor adjustment, but would save so many extra keystrokes.
AnitaInIndy
Re: My last sentence, this must be set to automatically remove extra spaces, so it is difficult to see the minor difference I am talking about, so you'll just have to try to rely on my description. Thanks for trying!!!
Ed Weber
Try this.
CODE
Sub Add_The_LowercaseNext()
With Selection
  .End = Selection.End + 1
  .Characters(1).Case = wdLowerCase
  .InsertBefore "The "
  .Collapse wdCollapseEnd
End With
End Sub
This is a "lo-fi" version of our main content. To view the full version with more information, formatting and images, please click here.
Invision Power Board © 2001-2010 Invision Power Services, Inc.