Dispatcher doesn't work in a Loop [Solved]

I am trying to paste the same text into multiple cells via a loop function:

	For n = 1 to TextTables(2).getRows().getCount() - 1
		Range = TemplateDoc.TextTables(2).getCellByPosition(4, n)
		TemplateDoc.getCurrentController.select(Range)
			dim args2(0) as new com.sun.star.beans.PropertyValue
			args2(0).Name = "SelectedFormat"
			args2(0).Value = 10
			dispatcher.executeDispatch(Frame, ".uno:ClipboardFormatItems", "", 0, args2())	
	Next

Currently I am getting the following error after the first pass:
BASIC runtime error.
An exception occurred
Type: com.sun.star.lang.IllegalArgumentException
Message: sequence element is not assignable by given value!.

Any ideas???

1 Like

dim args2(0) outside of For loop and the problem is resolved.

1 Like