Inserting Excel Range into Word

G

Guest

I have an excel workbook that performs assorted calculations. I am then
pasting the final output into an existing Word Document. Now I have been
able to open the word doc, find the text to insert the excel object in front
of. But it always leaves the text I searched for highlighted. I have not
been able to delete this text though.
So I really would like to open word, search for text, and REPLACE the text
with an OBJECT from excel. I don't mind inserting then deleting if need be.



Set objword = CreateObject("word.application")
objword.Visible = True

Set objdoc = objword.documents.Open("c:\Work.doc")
Set objselection = objword.Selection

objselection.Find.Text = "All products and services sold are to be listed
HERE."
objselection.Find.Forward = True
objselection.Find.matchwholeword = True

If objselection.Find.Execute Then
MsgBox ("Adding to Scope of Work Document")
objword.Selection.PasteSpecial link:=False, DataType:=wdPasteObject,
Placement:=wdInLine, DisplayAsIcon:=False
Else
MsgBox ("Unable to Modify Scope of Work Document")
End If


This part works. But how do I get rid of the text which is actually just a
placeholder?
 
G

Guest

If objselection.Find.Execute Then
MsgBox ("Adding to Scope of Work Document")

'Delete the found text
'Leaves objselectrion a single point in your document
objselection.Delete

objword.Selection.PasteSpecial link:=False, DataType:=wdPasteObject,
Placement:=wdInLine, DisplayAsIcon:=False

Etc.

-EW
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top