Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 38
Default Accessing word documents from Excel

I need to search through a directory of Word documents, check if a specified
word is in any of them, and if found paste the document name into Excel.

I'm working on this step by step!

First step is to access Word documents from within Excel. I have the
following code (for which I thank michelxld for his earlier posting) to test
whether I can open/copy from Word documents:

Sub importFromWord()

'Activate Word Object Library

Dim WordApp As Word.Application /// error arises here
Dim WordDoc As Word.Document

Set WordApp = CreateObject("word.application") ' Open Word session

WordApp.Visible = False 'keep word invisible
Set WordDoc = WordApp.Documents.Open("C:\test\test.doc") ' open Word file

'copy third row of first Word table
WordDoc.Tables(1).Rows(3).Range.Copy

'paste in Excel
Range("A1").PasteSpecial xlPasteValues

WordDoc.Close 'close Word doc
WordApp.Quit ' close Word

End Sub

There's an immediate error (marked /// above) with the message Compile Error
: User-Defined Type not Defined.

Could it be that I have to explicitly activate the Word object library (I've
copied the comment that michelxld included but suspect I should DO something
here!). If so, any pointers on what to do would be much appreciated - I've
searched these archives without finding anything but that may be because my
understanding is limited on this.

All comments gratefully received. If I can get this step working, onwards
and upwards to what I actually need to do!

Best wishes
SueJB

  #2   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 1
Default Accessing word documents from Excel


Hello SueJB

to activate the library :

in Visual basic editor (Alt+F11)
Tools
References
check the line "Microsoft Word xx.x Object Library"
Click "OK"

xx.x depend of your Office version

Regards ,
michel


--
michelxld
------------------------------------------------------------------------
michelxld's Profile: http://www.excelforum.com/member.php...o&userid=17367
View this thread: http://www.excelforum.com/showthread...hreadid=481833

  #3   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 38
Default Accessing word documents from Excel

Very many thanks!

Sue

"michelxld" wrote:


Hello SueJB

to activate the library :

in Visual basic editor (Alt+F11)
Tools
References
check the line "Microsoft Word xx.x Object Library"
Click "OK"

xx.x depend of your Office version

Regards ,
michel


--
michelxld
------------------------------------------------------------------------
michelxld's Profile: http://www.excelforum.com/member.php...o&userid=17367
View this thread: http://www.excelforum.com/showthread...hreadid=481833


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
I have an employee who is having problems accessing her documents AdminPhil Excel Discussion (Misc queries) 1 August 9th 05 08:27 PM
Accessing a Text Box in a Word Document from Excel Ben Excel Programming 1 November 12th 04 06:52 AM
Accessing Word Constants from Excel Ken Loomis Excel Programming 4 October 28th 04 06:39 PM
Accessing Word constants in Excel Ken Loomis Excel Programming 2 October 25th 04 10:57 PM
Accessing Word from Excel pikus Excel Programming 4 January 14th 04 07:41 PM


All times are GMT +1. The time now is 04:19 PM.

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"