Alexander was telling us:
Alexander nous racontait que :
"Jean-Guy Marcil" ?????:
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.
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...
--
Salut!
_______________________________________
Jean-Guy Marcil - Word MVP
(e-mail address removed)
Word MVP site:
http://www.word.mvps.org