
Range object, Selection object
I spoke too soon. I commented out my code and copied your
code directly into my VBEditor... it worked fine. I then
removed the comments from my code and changed it to the
following. It would seem this would be incorporating your
suggestion while retaining how my code gets the ALLCAPS
value in question. However an "invalid property" error
appears on r.Case wdTitleWord. i've looked at it a couple
times and I dont know if I am overlooking an obvious
problem or what. What do you think of the following
(variable names changed to protect the guilty)...
Dim strReturnValue As String
Dim objMyObject As DLLName.clsClass
Dim oRange As Range
On Error GoTo LocalErrorHandler
'Request the list:
Set objMyObject = New DLLName.clsClass
strReturnValue = objMyObject.GetReturnValues
Set objMyObject = Nothing
'Paste into current doc:
If Trim(strReturnValue) <> "" Then
Set oRange = ActiveDocument.Range
oRange.Collapse wdCollapseEnd
oRange.InsertAfter strReturnValue
oRange.Case wdTitleWord
End If
Quote:
>-----Original Message-----
>Hi muldoon,
>I think the following will take care of what you're
trying to accomplish:
Quote:
>Dim s As String
>Dim r As Range
>s = "ALLCAPS SENTENCE"
>Set r = ActiveDocument.Range
>r.Collapse wdCollapseEnd
>r.InsertAfter s
>r.Case = wdTitleWord
>HTH
Quote:
>> I do not know whether I should use a Range obj or
>> Selection obj. I suspect I need a Range but I don't know
>> how to set the Range object (oRange) initially.
>> I need to format some text as TitleCase (wdTitleWord).
The
>> text I am doing this to is a string:
>> Word.ActiveDocument.Range.InsertAfter strString
>> where strString is my "unformatted" (ie, ALLCAPS instead
>> of TitleCase) string.
>> The thing is, I need the text to be title case. Only my
>> string needs to be title case, not the rest of the
>> document. So I thought maybe I needed to use a Range
>> object in order to accomplish this.
>> set oRange = (this is what I don't know)
>> oRange.Text = strString
>> oRange.Case = wdTitleWord
>> Word.ActiveDocument.Range.InsertAfter oRange
>> But as you can see, my object variable (oRange) is not
>> set. How do I set oRange = something so that I can use
its
>> text and case properties and then paste in my TitleCase
>> text. Any advice appreciated.
>.