Add a picture to Word page

Add-in Express™ Support Service
That's what is more important than anything else

Add a picture to Word page
 
MediaMogul




Posts: 59
Joined: 2009-06-19
in my AddinModule.cs class, the automatically generated code includes:

public Word._Application WordApp
{
get
{
return (HostApplication as Word._Application);
}
}

I wish to add a picture to this WordApp using AddPicture(..)

Having seen this thread already: http://www.add-in-express.com/forum/read.php?FID=5&TID=5550
I had hoped that the line of code following would do the trick:

string filePath = "<a path>";

Word.Shape wShape = WordApp.ActiveDocument.Shapes.AddPicture(filePath, Type.Missing, Type.Missing, Type.Missing, Type.Missing, Type.Missing, Type.Missing, Type.Missing);

this is causing compile time errors: invalid arguments. Why's that?

Thanks for your help,
David.
Posted 26 Oct, 2009 08:28:18 Top
Andrei Smolin


Add-in Express team


Posts: 18821
Joined: 2006-05-11
David,

Note that the FileName parameter is described in the Word Developer Reference as follows:

The path and file name of the picture.



Andrei Smolin
Add-in Express Team Leader
Posted 26 Oct, 2009 08:54:16 Top
MediaMogul




Posts: 59
Joined: 2009-06-19
Andrei, the value of the string pathName is in fact fileInfo.FullName

I don't see how this causes a compile-time error.
Posted 26 Oct, 2009 11:06:06 Top
Andrei Smolin


Add-in Express team


Posts: 18821
Joined: 2006-05-11
David,

At http://www.add-in-express.com/forum/read.php?FID=5&TID=6290&MID=31208, I suggest checking Intellisense information on that method. In fact, this is a check of the Word interop that you are using. I'd also check the properties of the corresponding DLL.


Andrei Smolin
Add-in Express Team Leader
Posted 26 Oct, 2009 15:28:43 Top
MediaMogul




Posts: 59
Joined: 2009-06-19
Thanks Andrei, it's sorted.
Posted 27 Oct, 2009 08:46:41 Top