Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 7
Default Works in Personal.xls but not in normal workbook?

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

  #2   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 7
Default Works in Personal.xls but not in normal workbook?

Correction:
I'm using Excel 2003 (not 2000)

On Jun 2, 12:37 am, c mateland wrote:
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


  #3   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 7
Default Works in Personal.xls but not in normal workbook?

Never mind, thanks.

I had the Word library referenced only in Personal.xls. Once I
referenced it in the normal workbook, it was successful.


On Jun 2, 12:37 am, c mateland wrote:
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


Reply
Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules

Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On


Similar Threads
Thread Thread Starter Forum Replies Last Post
VB Works in test mode, but Stops when doing normal run. BEEJAY Excel Programming 1 September 22nd 06 07:03 PM
Excel Addin works that works on a template workbook s.jay_k Excel Programming 0 February 15th 06 07:31 PM
How to display as normal when workbook has been protected Lee Excel Worksheet Functions 1 July 4th 05 09:55 PM
Workbook page is not normal size Arden Excel Discussion (Misc queries) 1 June 30th 05 01:27 AM
Personal macro workbook and personal.xls John Kilkenny Excel Discussion (Misc queries) 1 June 14th 05 09:43 PM


All times are GMT +1. The time now is 11:19 AM.

Powered by vBulletin® Copyright ©2000 - 2024, Jelsoft Enterprises Ltd.
Copyright ©2004-2024 ExcelBanter.
The comments are property of their posters.
 

About Us

"It's about Microsoft Excel"