Adding picture to Word document using Excel -VBA generates out-of-memory error.
Posted on 2007-12-01
Using VBA in Excel 2003, I open a Word document using a template. After filling in fields and creating custom document properties in the document, I try to add a bitmap. I've tried to add it two different ways: 1) executing the AddPicture statement directly from Excel and 2) having Excel run a routine in the Word document that has the AddPicture statement in it. Here is the statement (SHP is declared as a WORD.Shape)
Set SHP = ActiveDocument.Shapes.AddPicture _
(PicFile,False, True,300,-26, , ,ActiveDocument.Bookmarks("bkSIG").Range)
As soon as the statement is executed, I get the error "There is insufficient memory. Save the document now." I've tried changing the Link and SaveWithFile parameters and eliminated the placement parameters, but nothing works. I tried it adding a 240k BMP file and a 20k JPG file.
I can switch to the Word document and execute the routine inside the Word document directly (without closing any other programs) and it works fine . I'm running SP3 for Office 2003 on a 2-gig machine under Windows XP SP2 with more than 80 gigs of available disk space. I've researched the error message extensively, but haven't found any relelvant solutions.