I have an ole ttype field in Access that hold snippets of word documents. Depending on the situation - certain Ole/word fields are filled into a bound object on a very important report. The reason we are using the ole is because the formatting must be preserved and there is a giff(or jpeg??) that must be within the text body.
Ok - heres the problem - it turns out that we need to insert varied text into thes ole documents so I've tried to manipulate word docs with the MS WORD 11.0 object library and then afterwards set am unbounded object field on the report to the word doc. I haven't gotten very far because it seems that I can't insert text in the body of the document - only at the end or beginning. This is a sample of the failed code - one of many attempts. The following code inserts "Hello" at the very beginning of the doc, not right before the word "test". I need either a better overall solution to manipulating OLE Word fields with VB or a down and dirty way to edit a word document with VB.
Dim oword As New Word.Application
Dim oDoc As New Word.Document
Set oDoc = oword.Documents.Add("C:\te
st.doc")
For i = 1 To oDoc.Words.count - 1
'search for a word to insert test afterwards.
If oDoc.Words(i) = "test" Then
oDoc.Content.InsertBefore ("hello")
End If
Next
oDoc.Close
Start Free Trial