Word Automation Problem

  • Thread starter Thierry Marneffe
  • Start date
T

Thierry Marneffe

Hello

I use Visual C++ to automate the creation of a Word document.
All is working fine, I insert header, footer, Toc, ....
In the last application I'm developping, I need to insert a lot of jpef
file. From 10 to 200 (and some times more), each beeing 100 to 200 Kb size.
I tried by adding picture that are saved to the word doc and then by simply
linking to an external file....
In both case (but later when doing external link), I got a small window 'Out
of Memory' ...

What shoudl I do to avoid this ? I guess having a 30 Mb file is not that
much with today's computers .... I got 512 MB on memory board and plenty of
space on the hard disk.....

Thansk for any clue solving this

Thierry


Here is the typical code I'm using :

#define vtTrue COleVariant(( short) TRUE)
#define vtFalse COleVariant(( short) FALSE)
#define vtOptional COleVariant(( long) DISP_E_PARAMNOTFOUND, VT_ERROR)
#define IntToVt( nInt) ( COleVariant(( short) nInt, VT_I2))

// Get In-Line Shapes

InlineShapes WordInlineShapes = WordSelection.GetInlineShapes();
InlineShape WordInlineShape = ( InlineShape) NULL;

WordSelection.InsertParagraph();

Range WordPicRange = WordSelection.GetRange();

// Set Source Range
// Note: AddPicture requires aVARIANT as the Range Parameter

LPDISPATCH lpPicDisp = WordPicRange;

VARIANT vtDisp;
vtDisp.vt = VT_DISPATCH;
vtDisp.pdispVal = lpPicDisp; // Assign IDispatch pointer of Range to
Variant

// Add Picture

if ( bLinkedToFile)
WordInlineShape = WordInlineShapes.AddPicture( strPicPath,
vtTrue, //
LinkToFile
vtFalse, //
SaveWithDocument
&vtDisp);
else
WordInlineShape = WordInlineShapes.AddPicture( strPicPath,
vtFalse, //
LinkToFile
vtTrue, //
SaveWithDocument
&vtDisp);

WordSelection.MoveDown( vtUnitLine, IntToVt(15), vtFalse);

// Clean Up

WordPicRange.DetachDispatch();

if ( WordInlineShape != ( InlineShape) NULL)
WordInlineShape.ReleaseDispatch();
WordInlineShapes.ReleaseDispatch();
 
B

Beth Melton

If you don't receive the answer you are looking for here then you may
want to post in one of the Word developers newsgroups since that's
where the gurus on these types of errors tend to hang out. :)

--
Please post all follow-up questions to the newsgroup. Requests for
assistance by email can not be acknowledged.

~~~~~~~~~~~~~~~
Beth Melton
Microsoft Office MVP

Word FAQ: http://mvps.org/word
TechTrax eZine: http://mousetrax.com/techtrax/
MVP FAQ site: http://mvps.org/
 

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