Need text from embedded Word object

C

c mateland

Excel 2003
WinXP
VBA References activated:
Visual Basic for Applications
Microsoft Excel 11.0 Object Library
OLE Automation
Microsoft Office 11.0 Object Library
Microsoft Word 11.0 Object Library

The following code successfully transcribes to A1 the text from an
embedded Word object, it leaves out characters such as tab and
paragraph characters. I need it to transcribe those as well so that
paragraphs, for example, actually start a new line in the cell, and
original tab spaces carry over as well.

Any way to do that?

Sub CopyText()
Application.ScreenUpdating = False
Dim oWord As Word.Document
Dim rWordText As Word.Range
Dim sText As String
Set oWord = ActiveSheet.OLEObjects("Object 1").Object
Set rWordText = oWord.Range
sText = rWordText
Range("a1").Value = sText
Application.ScreenUpdating = True
End Sub
 
C

c mateland

I reduced the code down to this, but it still will not copy paragraph
separations and tabs from the Word object. I know Excel uses ALT+Tab
for a new line, which is different from Word. And I know Excel has no
tab character. But is there a way to maybe substitute those characters
from Word with proper Excel characters?

Again, this transcribes text from an embedded Word object into A1, but
does not transcribe the needed paragraph breaks and tab spaces.

Any help on this? Thanks.

Sub CopyText()
Application.ScreenUpdating = False
Dim oWord As Word.Document
Dim rWordText As Word.Range
Set oWord = ActiveSheet.OLEObjects("Object 1").Object
Set rWordText = oWord.Range
Range("a1").Value = rWordText
Application.ScreenUpdating = True
End Sub
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top