C
c mateland
Excel 2000
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 simply transcribes into cell A1 the text from an
embedded Word object. It compiles without error and runs correctly
when ran from my Personal.xls on the active workbook. But it gives a
compile error when placed in in a module within a normal workbook.
I need it to run in a normal workbook from within its module. Any
help?
Sub GetWordText()
Application.ScreenUpdating = False
Dim objWord As Word.Application
Dim rngWordText As Word.Range
Dim strTextValue As String
ActiveSheet.OLEObjects(1).Activate
Set objWord = GetObject(, "Word.application")
Set rngWordText = objWord.ActiveDocument.Range
strTextValue = rngWordText.Text
With Range("a1")
.Value = strTextValue
.Activate
End With
Application.ScreenUpdating = True
End Sub
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 simply transcribes into cell A1 the text from an
embedded Word object. It compiles without error and runs correctly
when ran from my Personal.xls on the active workbook. But it gives a
compile error when placed in in a module within a normal workbook.
I need it to run in a normal workbook from within its module. Any
help?
Sub GetWordText()
Application.ScreenUpdating = False
Dim objWord As Word.Application
Dim rngWordText As Word.Range
Dim strTextValue As String
ActiveSheet.OLEObjects(1).Activate
Set objWord = GetObject(, "Word.application")
Set rngWordText = objWord.ActiveDocument.Range
strTextValue = rngWordText.Text
With Range("a1")
.Value = strTextValue
.Activate
End With
Application.ScreenUpdating = True
End Sub