
Signature
Salut!
_______________________________________
Jean-Guy Marcil - Word MVP
jmarcilREMOVE@CAPSsympatico.caTHISTOO
Word MVP site: http://www.word.mvps.org
> > Can somebody tell name of object for multiselections?
> >
[quoted text clipped - 4 lines]
> Are you selecting only the first and fifth (2 words), or from the first to
> the fifth word (five words)?
Yes. I select only first and fifth words. Then I want take last word in
selection.
The main task is more wide: User select some rows (for example 1st, 5th and
7th only, i.e. 3 rows) in a table, then copy it and paste. As result we must
obtain a table, but we obtain some paragraphs. I want write macros for this
operations, but don't know how get access to parts of multiselection.
Jean-Guy Marcil - 06 Sep 2005 13:58 GMT
Alexander was telling us:
Alexander nous racontait que :
> "Jean-Guy Marcil" ?????:
>
[quoted text clipped - 15 lines]
> write macros for this operations, but don't know how get access to
> parts of multiselection.
The multiselection isn't really supported in VBA. It usually only deals with
the last selection in the multiselection.
In your case, since you want to copy/paste, there is a solution. Try
something like:
'_______________________________________
Dim myRge As Range
Dim ColCount As Long
If Selection.Information(wdWithInTable) Then
ColCount = Selection.Tables(1).Columns.Count
Else
MsgBox "Selection must be in a table.", vbCritical, "Error"
Exit Sub
End If
Set myRge = ActiveDocument.Range
myRge.Collapse wdCollapseEnd
Selection.Copy
myRge.Paste
myRge.ConvertToTable wdSeparateByParagraphs, , ColCount
'_______________________________________
See the ConvertToTable method in the VBA help for more info on the
parameters you can use to format the table.
Also, if you have merged cells, the results may be a bit differently from
the original selection, and so will it be different if there are paragraph
marks in the original cells...

Signature
Salut!
_______________________________________
Jean-Guy Marcil - Word MVP
jmarcilREMOVE@CAPSsympatico.caTHISTOO
Word MVP site: http://www.word.mvps.org