Prev: Unable to permanently delete the MS Word custom toolbar
Next: Apply-user-defined table style only to tables with no vertically merged cells
From: mjlaali on 28 Mar 2010 06:12 Hi, how to detect that the end of a range is also end of a paragraph?
From: Graham Mayor on 28 Mar 2010 06:47 There are several ways including: Test whether the range and the last paragraph in the range have the same end eg If oRng.End = oRng.Paragraphs.Last.Range.End Then 'the range end is also a paragraph end. End If or see what the last character of the range is e.g. If oRng.Characters.Last = Chr(13) Then 'the range end is also a paragraph end End If or If oRng.Characters.Last = vbCr Then 'the range end is also a paragraph end End If -- <>>< ><<> ><<> <>>< ><<> <>>< <>><<> Graham Mayor - Word MVP My web site www.gmayor.com Word MVP web site http://word.mvps.org <>>< ><<> ><<> <>>< ><<> <>>< <>><<> "mjlaali" <mjlaali(a)discussions.microsoft.com> wrote in message news:29AD5B4B-7296-43EC-A3AC-BE7F6174C888(a)microsoft.com... > Hi, > > how to detect that the end of a range is also end of a paragraph?
From: macropod on 28 Mar 2010 06:59 Hi Graham, Not quite! Try selecting the 'paragraph mark' that defines the end of a table cell, then run the following macro: Sub Test() 'Graham's test MsgBox Selection.Characters.Last = Chr(13) 'Macropod's test MsgBox Asc(Selection.Characters.Last) = 13 End Sub -- Cheers macropod [Microsoft MVP - Word] "Graham Mayor" <gmayor(a)REMOVETHISmvps.org> wrote in message news:uA3UTQmzKHA.4328(a)TK2MSFTNGP04.phx.gbl... > There are several ways including: > > Test whether the range and the last paragraph in the range have the same end > eg > > If oRng.End = oRng.Paragraphs.Last.Range.End Then > 'the range end is also a paragraph end. > End If > > or see what the last character of the range is e.g. > > If oRng.Characters.Last = Chr(13) Then > 'the range end is also a paragraph end > End If > or > If oRng.Characters.Last = vbCr Then > 'the range end is also a paragraph end > End If > > -- > <>>< ><<> ><<> <>>< ><<> <>>< <>><<> > Graham Mayor - Word MVP > > My web site www.gmayor.com > Word MVP web site http://word.mvps.org > <>>< ><<> ><<> <>>< ><<> <>>< <>><<> > > > "mjlaali" <mjlaali(a)discussions.microsoft.com> wrote in message > news:29AD5B4B-7296-43EC-A3AC-BE7F6174C888(a)microsoft.com... >> Hi, >> >> how to detect that the end of a range is also end of a paragraph? > >
From: Graham Mayor on 28 Mar 2010 09:59 It could be argued that the table cell end marker is not a paragraph mark, but I take your point. :) -- <>>< ><<> ><<> <>>< ><<> <>>< <>><<> Graham Mayor - Word MVP My web site www.gmayor.com Word MVP web site http://word.mvps.org <>>< ><<> ><<> <>>< ><<> <>>< <>><<> "macropod" <macropod(a)invalid.invalid> wrote in message news:eiwnuWmzKHA.5348(a)TK2MSFTNGP02.phx.gbl... > Hi Graham, > > Not quite! Try selecting the 'paragraph mark' that defines the end of a > table cell, then run the following macro: > Sub Test() > 'Graham's test > MsgBox Selection.Characters.Last = Chr(13) > 'Macropod's test > MsgBox Asc(Selection.Characters.Last) = 13 > End Sub > > -- > Cheers > macropod > [Microsoft MVP - Word] > > > "Graham Mayor" <gmayor(a)REMOVETHISmvps.org> wrote in message > news:uA3UTQmzKHA.4328(a)TK2MSFTNGP04.phx.gbl... >> There are several ways including: >> >> Test whether the range and the last paragraph in the range have the same >> end eg >> >> If oRng.End = oRng.Paragraphs.Last.Range.End Then >> 'the range end is also a paragraph end. >> End If >> >> or see what the last character of the range is e.g. >> >> If oRng.Characters.Last = Chr(13) Then >> 'the range end is also a paragraph end >> End If >> or >> If oRng.Characters.Last = vbCr Then >> 'the range end is also a paragraph end >> End If >> >> -- >> <>>< ><<> ><<> <>>< ><<> <>>< <>><<> >> Graham Mayor - Word MVP >> >> My web site www.gmayor.com >> Word MVP web site http://word.mvps.org >> <>>< ><<> ><<> <>>< ><<> <>>< <>><<> >> >> >> "mjlaali" <mjlaali(a)discussions.microsoft.com> wrote in message >> news:29AD5B4B-7296-43EC-A3AC-BE7F6174C888(a)microsoft.com... >>> Hi, >>> >>> how to detect that the end of a range is also end of a paragraph? >>
From: Greg Maxey on 28 Mar 2010 10:39
Sub ScratchMaco() Dim oDoc As Word.Document Set oDoc = Documents.Add oDoc.Tables.Add oDoc.Range, 1, 1 MsgBox oDoc.Paragraphs.Count End Sub Both the end of cell and the end of row are counted as a parapraph :-( Graham Mayor wrote: > It could be argued that the table cell end marker is not a paragraph > mark, but I take your point. :) > > > "macropod" <macropod(a)invalid.invalid> wrote in message > news:eiwnuWmzKHA.5348(a)TK2MSFTNGP02.phx.gbl... >> Hi Graham, >> >> Not quite! Try selecting the 'paragraph mark' that defines the end >> of a table cell, then run the following macro: >> Sub Test() >> 'Graham's test >> MsgBox Selection.Characters.Last = Chr(13) >> 'Macropod's test >> MsgBox Asc(Selection.Characters.Last) = 13 >> End Sub >> >> -- >> Cheers >> macropod >> [Microsoft MVP - Word] >> >> >> "Graham Mayor" <gmayor(a)REMOVETHISmvps.org> wrote in message >> news:uA3UTQmzKHA.4328(a)TK2MSFTNGP04.phx.gbl... >>> There are several ways including: >>> >>> Test whether the range and the last paragraph in the range have the >>> same end eg >>> >>> If oRng.End = oRng.Paragraphs.Last.Range.End Then >>> 'the range end is also a paragraph end. >>> End If >>> >>> or see what the last character of the range is e.g. >>> >>> If oRng.Characters.Last = Chr(13) Then >>> 'the range end is also a paragraph end >>> End If >>> or >>> If oRng.Characters.Last = vbCr Then >>> 'the range end is also a paragraph end >>> End If >>> >>> -- >>> <>>< ><<> ><<> <>>< ><<> <>>< <>><<> >>> Graham Mayor - Word MVP >>> >>> My web site www.gmayor.com >>> Word MVP web site http://word.mvps.org >>> <>>< ><<> ><<> <>>< ><<> <>>< <>><<> >>> >>> >>> "mjlaali" <mjlaali(a)discussions.microsoft.com> wrote in message >>> news:29AD5B4B-7296-43EC-A3AC-BE7F6174C888(a)microsoft.com... >>>> Hi, >>>> >>>> how to detect that the end of a range is also end of a paragraph? |