View Single Post
  #1   Report Post  
Posted to microsoft.public.excel.programming
c mateland[_2_] c mateland[_2_] is offline
external usenet poster
 
Posts: 7
Default Need text from embedded Word object

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