Advertisement

05.02.2007 at 11:56AM PDT, ID: 22548493
[x]
Attachment Details

Manipulate WORD , OLE fields with VB or VBA

Asked by janmishkin in Windows OLE Programming, Access Reports, Visual Basic v1.0.5.x

Tags: word, ole, vba, vb

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:\test.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
[+][-]05.02.2007 at 03:05PM PDT, ID: 19019682

At Experts Exchange, members can ask their questions to thousands of technology professionals, also known as Experts. Experts compete and collaborate to answer those questions by leaving comments like this one.

Start your 7-day free trial to view this Expert Comment or ask the Experts your question.

 
[+][-]05.03.2007 at 12:39PM PDT, ID: 19026181

Often, when Experts are collaborating with members who have asked questions, they will request additional information about the problem. Askers respond with an author comment like this one.

Start your 7-day free trial to view this Author Comment or ask the Experts your question.

 
[+][-]05.03.2007 at 12:49PM PDT, ID: 19026278

View this solution now by starting your 7-day free trial. Setting up your free trial is quick, easy, and secure. We will return you to this solution, unlocked, when you're done.

 

About this solution

Zones: Windows OLE Programming, Access Reports, Visual Basic v1.0.5.x
Tags: word, ole, vba, vb
Sign Up Now!
Solution Provided By: jefftwilley
Participating Experts: 1
Solution Grade: C
 
 
[+][-]05.07.2007 at 09:58AM PDT, ID: 19044041

At Experts Exchange, members can ask their questions to thousands of technology professionals, also known as Experts. Experts compete and collaborate to answer those questions by leaving comments like this one.

Start your 7-day free trial to view this Expert Comment or ask the Experts your question.

 
 
Loading Advertisement...
20080716-EE-VQP-32