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();
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();