How to read a Word Document from Ms Access

  • Thread starter Thread starter Upendra
  • Start date Start date
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
 
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.
 
Back
Top