Embedded Word Document not painted until I click on it and activate it with the mouse

C

Chad Knudson

I'm generating reports in Excel and one of them has an embedded Word
document. I can create the embedded Word document just fine but I don't end
up with the document painting in Excel, I have just a white box. If I click
on the embedded Word document to activate it, all of my text is there and
clicking away leaves me with the desired result. What am I missing to get
Word to paint this? I'm inside a section that has Excel's
Application.ScreenUpdating = False in case that affects anything.

(wsReports is an Excel worksheet)

Dim shpEmbeddedWordDoc As Shape
Dim objWord As Object

Set shpEmbeddedWordDoc=
wsReports.Shapes.AddOLEObject(ClassType:="Word.Document.8", Left:=334#,
Top:=4977#, Width:=320#, Height:=144#)
Set objWord = wsReports.OLEObjects(1).Object

objWord.Activate
objWord.StoryRanges(1).Text = "This is the contents of the document"

I seem to be missing something to get this to initially draw.
 
C

Chad Knudson

Found out that I needed to activate it after putting in all of the content
into the doc to force it to paint.
 

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