Inserting Picture in MS Word from VB exe

A

Arjan

Hi, trying to set the wdWrapSquare property for a picture that I insert from
within an VB application exe.
Error says:'The Object is not valid' (See code line)
So the question is, how can I refer to the picture I have inserted?

Thanx in advance.
Arjan

--Code:
Dim Doc As Word.Document
Dim wordApp As Word.Application

' Create new hidden instance of Word.
Set wordApp = CreateObject("Word.Application")
Set Doc = wordApp.Documents.Open(FileName:="C:\Test.doc")

Doc.Shapes.AddPicture FileName:="C:\test.jpg", LinkToFile:=False,
SaveWithDocument:=True, Left:=30, Top:=50

Doc.Shapes(1).Select

--->> Error on this line: Selection.ShapeRange.WrapFormat.Type =
wdWrapSquare

wordApp.Quit
Set wordApp = Nothing

--EndOfCode
 
A

Arjan

Thanx for replying.

Unfortunately, it still doesn't work.
I get an error on: Set myShape =
Doc.Shapes.AddPicture(FileName:="C:\test.jpg",............
It reads: 'Type Mismatch' (13)

Any suggestions?

Arjan
 
A

Arjan

Figured it out!!

Thanx.

(Dim myShape as Word.Shape and WordApp.Selection... does the trick!)

Grtz. Arjan
 

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