You can see that the Words
type is a non-generic enumerable -- so the compiler can't infer the generic type parameter for ForEach<TSource>
. You could make the collection into a typed generic collection by using OfType<Range>
:
Parallel.ForEach(selection.Words.OfType<Microsoft.Office.Interop.Word.Range>(), range =>
{
});