[AccessD] Scrape Word

Bob Heygood bheygood at abestsystems.com
Fri Apr 15 16:52:06 CDT 2005


yes in a table cell.
again your code is working super.
but only grabs the first word, sometimes there is more than one word in the
cell, and I would like to capture all of them.
if you have thought, I would welcome it.


again I tried to manipulate the code further but it acts very erratic when
in a table cell.

thanks for the great help.

bob


-----Original Message-----
From: accessd-bounces at databaseadvisors.com
[mailto:accessd-bounces at databaseadvisors.com]On Behalf Of Hale, Jim
Sent: Thursday, April 14, 2005 12:53 PM
To: 'Access Developers discussion and problem solving'
Subject: RE: [AccessD] Scrape Word


So the data you want (including the search string) is in a table cell? In
the code I sent you delete
   wd.Selection.Start = wd.Selection.End
   Call wd.Selection.EndOf(wdSentence, wdExtend)

and replace with
   wd.Selection.Next(Unit:=wdWord, Count:=1).Select

Or if the entire string is returned you can replace the search string with
an empty string "" using the following function:

Function ReplaceString(strTextIn As String, strFind As String, strReplace As
String, fCaseSensitive As Boolean) As String

  Dim strTmp As String
  Dim intPos As Integer
  Dim intCaseSensitive As Integer

  intCaseSensitive = IIf(fCaseSensitive, 2, 1)

  strTmp = strTextIn
  intPos = InStr(1, strTmp, strFind, intCaseSensitive)

  Do While intPos > 0
    strTmp = Left$(strTmp, intPos - 1) & strReplace & Mid$(strTmp, intPos +
Len(strFind))
    intPos = InStr(intPos + Len(strReplace), strTmp, strFind,
intCaseSensitive)
  Loop

  ReplaceString = strTmp

End Function

Jim Hale

-----Original Message-----
From: Bob Heygood [mailto:bheygood at abestsystems.com]
Sent: Thursday, April 14, 2005 12:12 PM
To: Access Developers discussion and problem solving
Subject: RE: [AccessD] Scrape Word


Hey Jim,
Thanks again for the code it works just fine except for when I use it for my
actual project.
When using your code in a table in Word it retrieves the text of interest
okay, but also includes the search string.
After much testing I find this only happens in the table, which of course is
where I need to cull the data from.
I have looked at selection.movestart and some other Word functions to no
avail.
Would you have any ideas?

bob



-----Original Message-----
From: accessd-bounces at databaseadvisors.com
[mailto:accessd-bounces at databaseadvisors.com]On Behalf Of Hale, Jim
Sent: Monday, April 11, 2005 12:43 PM
To: 'Access Developers discussion and problem solving'
Subject: RE: [AccessD] Scrape Word


Here is some quick and dirty code that opens a Word doc from inside Access,
searches for the string "special code:" and sets a string variable equal to
the sentence that follows the code string. If your documents all have the
same string you can find that string and select words, sentences or
paragraphs that come after it. HTH
Jim Hale

Function LiftText()

Dim wd As Word.Application, strPhrase As String, strFindphrase As String
strFindphrase = "special code:"
Set wd = New Word.Application
wd.Documents.Open "C:\Test.doc"
wd.Visible = True
wd.Selection.Find.ClearFormatting
    With wd.Selection.Find
        .Text = strFindphrase
        .Replacement.Text = ""
        .Forward = True
        .Wrap = wdFindContinue
        .Format = False
        .MatchCase = False
        .MatchWholeWord = False
        .MatchWildcards = False
        .MatchSoundsLike = False
        .MatchAllWordForms = False
    End With
    wd.Selection.Find.Execute
    wd.Selection.Start = wd.Selection.End
   Call wd.Selection.EndOf(wdSentence, wdExtend)
    strPhrase = wd.Selection
    MsgBox "Look what I found: " & strPhrase
    wd.ActiveDocument.Close
    wd.Quit
    Set wd = Nothing
End Function

-----Original Message-----
From: Bob Heygood [mailto:bheygood at abestsystems.com]
Sent: Monday, April 11, 2005 12:52 PM
To: Access Developers discussion and problem solving
Subject: RE: [AccessD] Scrape Word


sounds good but their tech guy says does not work with Word.

thanks anyway.



-----Original Message-----
From: accessd-bounces at databaseadvisors.com
[mailto:accessd-bounces at databaseadvisors.com]On Behalf Of Hale, Jim
Sent: Monday, April 11, 2005 6:30 AM
To: 'Access Developers discussion and problem solving'
Subject: RE: [AccessD] Scrape Word


Monarch is a good solution. It has an object model that can be programmed
from Access. I use it to extract data from text files directly into Access.
Jim Hale

-----Original Message-----
From: Bob Heygood [mailto:bheygood at abestsystems.com]
Sent: Saturday, April 09, 2005 3:07 PM
To: Access Developers discussion and problem solving
Subject: [AccessD] Scrape Word


Hello to the list,

I am looking to programmically extract data from about 250 Word docs.
It appears that there are no bookmarks, fields or table structure.

It also looks like all data are in the same place and associated with the
same phrase ahead of the data of interest.

So, if I "find" the proper phrase and capture the text after it, I think
that will do. Issues like how to know when to stop and such will be
interesting.


thots?

best,

bob

accesspro at nospamcox.net


--
AccessD mailing list
AccessD at databaseadvisors.com
http://databaseadvisors.com/mailman/listinfo/accessd
Website: http://www.databaseadvisors.com

***********************************************************************
The information transmitted is intended solely for the individual or
entity to which it is addressed and may contain confidential and/or
privileged material. Any review, retransmission, dissemination or
other use of or taking action in reliance upon this information by
persons or entities other than the intended recipient is prohibited.
If you have received this email in error please contact the sender and
delete the material from any computer. As a recipient of this email,
you are responsible for screening its contents and the contents of any
attachments for the presence of viruses. No liability is accepted for
any damages caused by any virus transmitted by this email.

--
AccessD mailing list
AccessD at databaseadvisors.com
http://databaseadvisors.com/mailman/listinfo/accessd
Website: http://www.databaseadvisors.com

***********************************************************************
The information transmitted is intended solely for the individual or
entity to which it is addressed and may contain confidential and/or
privileged material. Any review, retransmission, dissemination or
other use of or taking action in reliance upon this information by
persons or entities other than the intended recipient is prohibited.
If you have received this email in error please contact the sender and
delete the material from any computer. As a recipient of this email,
you are responsible for screening its contents and the contents of any
attachments for the presence of viruses. No liability is accepted for
any damages caused by any virus transmitted by this email.


--
AccessD mailing list
AccessD at databaseadvisors.com
http://databaseadvisors.com/mailman/listinfo/accessd
Website: http://www.databaseadvisors.com

***********************************************************************
The information transmitted is intended solely for the individual or
entity to which it is addressed and may contain confidential and/or
privileged material. Any review, retransmission, dissemination or
other use of or taking action in reliance upon this information by
persons or entities other than the intended recipient is prohibited.
If you have received this email in error please contact the sender and
delete the material from any computer. As a recipient of this email,
you are responsible for screening its contents and the contents of any
attachments for the presence of viruses. No liability is accepted for
any damages caused by any virus transmitted by this email.





More information about the AccessD mailing list