Loop through MS Word Object (StoryRanges) Using For Loop
Posted: 18 Jun 2016, 10:15
Hey guys, could anybody please help me with figuring out how to loop through the StoryRanges object in MS Word?
The testing code is located below. It fails at "For myStoryRange, In StoryRange" with the error message '_NewEnum' is not a method.
Also tried this, but no luck, same error.
Thanks
The testing code is located below. It fails at "For myStoryRange, In StoryRange" with the error message '_NewEnum' is not a method.
Code: Select all
^Space::
oWord := ComObjActive("Word.Application")
StoryRange := {}
StoryRange := oWord.ActiveDocument.StoryRanges
For myStoryRange, In StoryRange
{
myStoryRange.Text := "Hello"
}
return
Code: Select all
^Space::
oWord := ComObjActive("Word.Application")
StoryRange := {}
StoryRange := ComObjArray(ComObjType(oWord.ActiveDocument.StoryRanges.Item(1)), 8)
StoryRange := oWord.ActiveDocument.StoryRanges
For myStoryRange, In StoryRange
{
myStoryRange.Text := "Hello"
}
return