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

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
Avatar of Rgonzo1971
Rgonzo1971

Hi,

pls try
Me.WordDocData.SetFocus
 Dim blnFound As Boolean
 With Me.WordDocData.Range.Find
 .ClearFormatting
 .Text = ""
 .Style = "Scene"
 Do
 blnFound = .Execute Format:=True
 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 

Open in new window

Regards
Avatar of Armando Vilela Baiões

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
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
Thanks for your help! That worked just fine!