How to read a Word Document from Ms Access

U

Upendra

Hi,

I need to read an information which is located in a Word
Document. It doesn't contain any book marks or so. Let me
know how can I read the Word Document from Ms Access and
get that data to the memo field of my database.

Can you please suggest me any links to websites regarding
this information.

Regards,
Upendra
 
R

Rudy

Upendra,

Could this function be of any help?

Public Function GetMemo(strPath As String, strFileName As
String, strSearchString As String, strEndSign As String)
As Variant
Dim varText As Variant
Dim wrdObject As Word.Application

Set wrdObject = GetObject(, "Word.Application")
wrdObject.Visible = False
wrdObject.Documents.Open strPath & strFileName & ".doc"
Selection.HomeKey Unit:=wdStory
Selection.Find.ClearFormatting
Selection.Find.Text = strSearchString
Selection.Find.Execute
Selection.HomeKey Unit:=wdLine
Selection.MoveDown Unit:=wdLine, Count:=1
varText = ""
Selection.MoveRight Unit:=wdCharacter, Count:=1,
Extend:=wdExtend
Do While Selection.Characters(1) <> strEndSign
varText = varText & Selection.Characters(1)
Selection.MoveRight Unit:=wdCharacter, Count:=1
Selection.MoveRight Unit:=wdCharacter, Count:=1,
Extend:=wdExtend
Loop
GetMemo = varText
wrdObject.Documents.Close SaveChanges:=False
wrdObject.Visible = False
Set wrdObject = Nothing

End Function

R.W.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top