Java: Add a picture into a word document
Hi All,
I need to insert a image into a word document. I have not found any sample source in Java. I tried to take the idea about how to do it form Visual Basic. Here is my code:
//Open the doc file "file.doc"
WordDocument doc = null;
WordDocs docs = null;
docs = getDocsReference();
this.visibilidad = true;
doc = this.opendocument(docs, "W:/file.doc");
//Select the bookmark
this.doc.getBookmarks().Item("bookmark").Select();
Object oMissing = new Object();
//insert the barcode
this.doc.getInlineShapes().AddPicture("W:/image.jpg",oMissing,oMissing,oMissing); //line 11
I inserted manually a bookmark named "bookmark" in the document file.doc and then I ran the code above receiving "Type mismatch" error while line 11 was running. Does anybody know what I'm doing wrong?
In fact, I think it could be a problem in AddPicture function parameters as I don't know which values assign to the object oMissing. Does anybody know which values should oMissing object have?
I'm using msword library (msword brigde).
If someone could give me advise on this it will be most appreciated!
Many Thanks
[1202 byte] By [
rpradaa] at [2007-11-27 11:26:11]

Thanks TuringPest!,
But I meant if someone knows how to fill the parameters of the function addPicture. This parameters are: (String, Object, Object, Object)
The first one is so clear (path of the image file) but the rest ones are mandatory and I really don't know how to fill them. As far as I could see in VB the second one and the third one are filled like boolean types, is there any way to create and object and assign to it a boolean value? I tried but there is no possibility to convert from boolean to object.
Kind Regards
> But I meant if someone knows how to fill the
> parameters of the function addPicture. This
I'm pretty sure the creators of that library do.
> parameters are: (String, Object, Object, Object)
Consider reading the docs I'd say.
> The first one is so clear (path of the image file)
> but the rest ones are mandatory and I really don't
> know how to fill them. As far as I could see in VB
> the second one and the third one are filled like
> boolean types, is there any way to create and object
> and assign to it a boolean value? I tried but there
> is no possibility to convert from boolean to object.
Ever seen Boolean?