View Single Post
 
Old 08-18-2021, 09:16 PM
Peterson Peterson is offline Windows 10 Office 2019
Competent Performer
 
Join Date: Jan 2017
Posts: 143
Peterson is on a distinguished road
Default

Thanks for your help and explanation, Andrew. I'm afraid I've failed to describe just what I'm trying to achieve.

The overall objective is to:
  1. Extract capitalized text from the beginning of a document
  2. Pass the text to a function that converts it to camel case
  3. Pass the camel-case text back and do other stuff
In my code yesterday, I included the following line to set the range:
Code:
Set rngTitle = ActiveDocument.Words(1)
I actually don't want the first word in the document to be the range. I only used this code because I can't otherwise figure out how to convert the all-cap'd text to a range, which I assume is necessary in order to run the text through the MakeTitleCase code, as there's no user-selected text, so Selection can't be used. Among other attempts, I tried the following, which doesn't work:
Code:
Set rngTitle.Text = "SECTION 00 00 00, ETC."
I think I'm misunderstanding the range concept; that is, perhaps a range can apply only to some portion of a document?? I'm stuck on it because I don't know how else to get around the Selection issue. Or maybe I need to do this differently, by parsing the entire string, evaluating each word on its own, then re-assembling?? In other words, Allen's macro really only works for user-selected text and trying to convert it to work on a range won't work, in this case (sorry, bad pun).

Thanks again.
Reply With Quote