View Single Post
  #10   Report Post  
Posted to microsoft.public.word.tables
Michael Koerner Michael Koerner is offline
external usenet poster
 
Posts: 41
Default Borders and Shading

Thanks Doug. Where does one insert this in the original macro?

--

Regards
Michael Koerner


"Doug Robbins - Word MVP" wrote in message ...
I glad that fellow MVP stepped in to sort that out.

Re the white space, when you split a table, a paragraph mark is inserted between the two tables, so you will need to apply appropriate formatting to that paragraph mark - probably formatting the font as hidden

The following code splits a table at the row in which the selection is located and then formats the font of the paragraph between the two tables so that it is hidden:

Dim arow As Row
Dim arange As Range
Set arow = Selection.Rows(1)
Selection.Tables(1).Split arow
Set arange = arow.Range
arange.start = arange.start - 1
arange.Collapse wdCollapseStart
arange.Paragraphs(1).Range.Font.Hidden = True


--
Hope this helps.

Please reply to the newsgroup unless you wish to avail yourself of my
services on a paid consulting basis.

Doug Robbins - Word MVP

"Michael Koerner" wrote in message ...
Using this line

dtable.Split BeforeRow:=newrow

seems to work okay. Now how does one go about removing all thw whitespace between the tables?

--

Regards
Michael Koerner


"Jay Freedman" wrote in message ...
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.