Words.Words cannot be indexed

Add-in Express™ Support Service
That's what is more important than anything else

Words.Words cannot be indexed
James Thomas

Posts: 5
Joined: 2015-09-11
I'm getting the error code

Words.Words cannot be indexed because it has no default property

When i try to execute the code below -

Dim Para As Word.Paragraph, rng As Word.Range, iLvl As Long
If Para.Range.Words(1) = "(" and Para.Range.Words(2) Like "[0-9]" and Para.Range.Words(3) = ")" Then rng.ParagraphFormat.Style = "STYLE1"

I'm converting from an old VBA Macro so apologies if this is obvious but I can't make this work.

The objective of the code is to check the first 3 characters of a line in word to see if they conform to a certain format and if so apply a style to the paragraph.

Any help greatly appreciated.


Posted 15 Sep, 2015 21:55:25 Top
Andrei Smolin

Add-in Express team

Posts: 17375
Joined: 2006-05-11
Hello James,

Try replacing Words(index) with Words.Item(index).Text.

Regards from Belarus (GMT+3),

Andrei Smolin
Add-in Express Team Leader
Posted 16 Sep, 2015 02:21:32 Top