codewala

code it

macro to select only text from table cell in Word

When I used to copy content from Word from selected table cell into PowerPoint the para formatting used to get lost. To retain the para formatting only the text from the table cell should be copied.

Below is the macro on how to select only the text from a selected table cell.


Sub select_text()
'
Dim oDoc As Document
Dim oRng As Range
'
Set oDoc = ActiveDocument
'
oDoc.Tables(1).Rows(1).Cells(1).Select
'
Set oRng = Selection.Cells(1).Range.Paragraphs(1).Range
oRng.End = oRng.Cells(1).Range.End - 1
oRng.Select
'
End Sub

Advertisements

April 11, 2011 - Posted by | VBA, Word

No comments yet.

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s

%d bloggers like this: