Armando Vilela Baiões
asked on
find a specific style and pass it to a access table
I'm trying to populate a table with data that I take from a word document, but I can not figure out where I'm going wrong. Anyone have any ideas or suggestions for what I'm doing wrong? The word document is loaded into an OLE object and this is the code I am using:
Me.WordDocData.SetFocus
Dim blnFound As Boolean
With Me.WordDocData.Range.Find
.Style = "Scene"
Do
blnFound = .Execute
If blnFound Then
Dim xyz As String
xyz = WordDocData.Range.Text
DoCmd.RunSQL "insert into tblCabecalhos (cabecalho) values ('" & xyz & "');"
Me.frmCabecalhos.Requery
Else
Exit Do
End If
Loop
End With
Me.WordDocData.SetFocus
Dim blnFound As Boolean
With Me.WordDocData.Range.Find
.Style = "Scene"
Do
blnFound = .Execute
If blnFound Then
Dim xyz As String
xyz = WordDocData.Range.Text
DoCmd.RunSQL "insert into tblCabecalhos (cabecalho) values ('" & xyz & "');"
Me.frmCabecalhos.Requery
Else
Exit Do
End If
Loop
End With
ASKER
I tried the solution but I have the same problem. The code just fetches the first paragraph and repeats over the records, instead of making a new record from the next style in document ... I can not figure out why, I've never coded anything like this and I'm out of ideas. I'll leave a screenshot here, you might be able to help me like this.
problem.jpg
problem.jpg
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
ASKER
Thanks for your help! That worked just fine!
pls try
Open in new window
Regards