Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.misc
external usenet poster
 
Posts: 5
Default Reading Word document by using Excel Macro

Can anyone tell me how to read each character from the word document by using
the Excel Macro.
  #2   Report Post  
Posted to microsoft.public.excel.misc
external usenet poster
 
Posts: 9,101
Default Reading Word document by using Excel Macro

Here is three very similar methods

by characters

Sub getcharacters()

Set WdObj = GetObject("c:\temp\test.doc")

RowCount = 1
For Each Char In WdObj.Characters
For CharCount = 1 To Len(Wd)
Range("A" & RowCount) = Mid(Wd, CharCount)
RowCount = RowCount + 1
Next CharCount
Next Char
WdObj.Close
End Sub

By Word

Sub getwords()

Set WdObj = GetObject("c:\temp\test.doc")

RowCount = 1
For Each Wd In WdObj.Words
Range("A" & RowCount) = Wd
RowCount = RowCount + 1
Next Wd
WdObj.Close
End Sub


To use the words to get the characters

Sub getletters()

Set WdObj = GetObject("c:\temp\test.doc")

RowCount = 1
For Each Wd In WdObj.Words
For CharCount = 1 To Len(Wd)
Range("A" & RowCount) = Mid(Wd, CharCount)
RowCount = RowCount + 1
Next CharCount
Next Wd
WdObj.Close
End Sub


"Arvind Mane" wrote:

Can anyone tell me how to read each character from the word document by using
the Excel Macro.

  #3   Report Post  
Posted to microsoft.public.excel.misc
external usenet poster
 
Posts: 5
Default Reading Word document by using Excel Macro

Thank you Joel, its working fine.

"Joel" wrote:

Here is three very similar methods

by characters

Sub getcharacters()

Set WdObj = GetObject("c:\temp\test.doc")

RowCount = 1
For Each Char In WdObj.Characters
For CharCount = 1 To Len(Wd)
Range("A" & RowCount) = Mid(Wd, CharCount)
RowCount = RowCount + 1
Next CharCount
Next Char
WdObj.Close
End Sub

By Word

Sub getwords()

Set WdObj = GetObject("c:\temp\test.doc")

RowCount = 1
For Each Wd In WdObj.Words
Range("A" & RowCount) = Wd
RowCount = RowCount + 1
Next Wd
WdObj.Close
End Sub


To use the words to get the characters

Sub getletters()

Set WdObj = GetObject("c:\temp\test.doc")

RowCount = 1
For Each Wd In WdObj.Words
For CharCount = 1 To Len(Wd)
Range("A" & RowCount) = Mid(Wd, CharCount)
RowCount = RowCount + 1
Next CharCount
Next Wd
WdObj.Close
End Sub


"Arvind Mane" wrote:

Can anyone tell me how to read each character from the word document by using
the Excel Macro.

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
Opening a Word Document using an Excel (2000) Macro? ekreider Excel Discussion (Misc queries) 4 January 5th 08 04:41 AM
convert excel document to word document (not a picture) frendabrenda1 Excel Discussion (Misc queries) 2 October 6th 06 03:55 PM
help creating a macro in excel that opens a specific word document Prohock Excel Discussion (Misc queries) 3 March 30th 06 04:58 PM
2 questions: Using solver in Macro AND converting to Word document to print A3 yendor28 Excel Discussion (Misc queries) 3 November 17th 05 07:55 PM
Reading data in onther Excel document Ernest Excel Worksheet Functions 1 August 24th 05 01:34 PM


All times are GMT +1. The time now is 08:42 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"