Link to home
Start Free TrialLog in
Avatar of Armando Vilela Baiões
Armando Vilela BaiõesFlag for Portugal

asked on

select parts of text in a word doc OLE an pass it to another OLE field

I have a word document loaded in access form inside a OLE. my question is is it possible to select the text between, lets say .Style "Scene" and .Style "Cut"
and copy it?
example

.Style "scene"
bla bla bla
bla bla bla
bla bla
.Style "Cut"

then again Style "Scene"

bla bla
bla

.Style "Cut"

and so forth till the end of document?
Avatar of Rgonzo1971
Rgonzo1971

Hi,

pls try
Me.WordDocData.SetFocus
Set rngSearch = Me.WordDocData.Range
With rngSearch.Find
    Do
        idx = idx + 1
        .ClearFormatting
        .Text = ""
         .Style = "Scene"
        .Forward = True
        .Format = True
        .Execute
        rngSearch.Collapse wdCollapseEnd
        rngStart = rngSearch.End
        .ClearFormatting
        .Text = ""
        .Style = "Cut"
        .Forward = True
        .Format = True
        .Execute
        rngSearch.Collapse wdCollapseStart
        rngEnd = rngSearch.Start
        If rngStart <> rngEnd Then
            Set myRange = ActiveDocument.Range(rngStart, rngEnd)
            Dim xyz As String
            xyz = myRange.Text
            DoCmd.RunSQL "insert into tblCabecalhos (cabecalho) values ('" & xyz & "');"
            Me.frmCabecalhos.Requery
        Else
            Exit Do
        End If
     Loop While .Found = True And idx < 1000
End With

Open in new window

Regards
ASKER CERTIFIED SOLUTION
Avatar of Rgonzo1971
Rgonzo1971

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial