TextRange VBA question

  • Thread starter Thread starter Guest
  • Start date Start date
G

Guest

I have the following snippet of code:

With .TextFrame
.TextRange.Text = DataArray(PgmRow, 8)
Call TextRangeFontUpdate(.TextRange)
End With

---

Sub TextRangeFontUpdate(TextRange As TextRange)

With TextRange.Text <~~~error on this line

blah blah blah

End With


I get the error of "With object must be user-defined type, object or variant"

What am I doing wrong?

Thanks,
Barb Reinhardt
 
I'm not sure that this is the problem, but it is never good practice to
name your variables with names that are used for something else. Change

Sub TextRangeFontUpdate (TextRange As TextRange)
With TextRange.Text

to something like:

Sub TextRangeFontUpdate (myTextRange As TextRange)
With myTextRange.Text

--David

--
David M. Marcovitz
Microsoft PowerPoint MVP
Director of Graduate Programs in Educational Technology
Loyola College in Maryland
Author of _Powerful PowerPoint for Educators_
http://www.PowerfulPowerPoint.com/

=?Utf-8?B?QmFyYiBSZWluaGFyZHQ=?=
 
I agree with the naming and don't usually do that. I've made the change, but
still get the same error.

Any other suggestions?
 
David,

I tried splitting out the WITH statements to see what part it didn't like.

I now have

With myTextRange
With .Text <~~~~ error here
blah blah blah
End With
End With
 
OK. That's a good start. The questino is why would you put .Text as part
of a With block? Generally, the With block is used to eliminate the need
for everything before a dot. There are not dots after .Text

I would normally have something like:

With myTextRange
.Text = .Text & "blah blah"
End With

I believe this is what the error message is telling you.

--David

--
David M. Marcovitz
Microsoft PowerPoint MVP
Director of Graduate Programs in Educational Technology
Loyola College in Maryland
Author of _Powerful PowerPoint for Educators_
http://www.PowerfulPowerPoint.com/

=?Utf-8?B?QmFyYiBSZWluaGFyZHQ=?=
 
I now know that. I think I've figured out what I need to do. I'm still
learning what's contained in PowerPoint objects.
 
Great. Let us know if it works, or ask more questions if it doesn't.
--David

--
David M. Marcovitz
Microsoft PowerPoint MVP
Director of Graduate Programs in Educational Technology
Loyola College in Maryland
Author of _Powerful PowerPoint for Educators_
http://www.PowerfulPowerPoint.com/

=?Utf-8?B?QmFyYiBSZWluaGFyZHQ=?=
 
Now I'm having another problem.

I have the following statement

StartVal = InStr(1, myTextRange.Text, myPattern, vbBinaryCompare)

And it doesn't seem to be counting any of the line breaks on the text.
 
I am finding that it is counting the line breaks twice (probably as line
break/carriage return or something). Are you expecting it to count the
automatic line breaks from word wrap? Those aren't characters, so they
shouldn't count. It should only count the ones that you actually type.
--David

--
David M. Marcovitz
Microsoft PowerPoint MVP
Director of Graduate Programs in Educational Technology
Loyola College in Maryland
Author of _Powerful PowerPoint for Educators_
http://www.PowerfulPowerPoint.com/

=?Utf-8?B?QmFyYiBSZWluaGFyZHQ=?=
 
Back
Top