Michael Koerner wrote:
Doug; thanks for taking the time. Greatly appreciated. The macro
gives me a Run-time error '5': Invalid procedure call,and when I
click on debug the following line is highlighted.
If initrng.Characters(1) Init Then
Set newrow = dtable.Rows.Add(BeforeRow:=dtable.Rows(i + 1))
dtable.Split (newrow)
With newrow
Very interesting behavior...
When you call a method and you don't use its return value (that is, you use
it as a subroutine and not as a function), VBA prefers that you don't
enclose the argument in parentheses and in some cases considers it an error
(
http://www.word.mvps.org/FAQs/Macros...thArgmnts.htm).
So changing the Split call to
dtable.Split BeforeRow:=newrow
or just
dtable.Split newrow
will work without errors.
According to the Help topic on the Split method, the argument can be either
a Row object (which newrow is) or the row number. That means you could write
the line as
dtable.Split BeforeRow:=newrow.Index
or just
dtable.Split newrow.Index
But now comes the odd part. You can write the line as
dtable.Split (newrow.Index)
and the macro will still work without errors, even though the parentheses
are "wrong". But this line gets a compiler error:
dtable.Split (BeforeRow:=newrow.Index)
--
Regards,
Jay Freedman
Microsoft Word MVP FAQ:
http://word.mvps.org
Email cannot be acknowledged; please post all follow-ups to the newsgroup so
all may benefit.