how does one insert a picture in word?

N

neonico

hi everybody!
here is the code which allows the merging of my table:
<code merging of table>
oRange = oSelection.GetRange();
oTables = oDoc.GetTables();
oTable = oTables.Add(oRange,nb_lignes,1,vtOptional,vtOptional);
oTable.AutoFormat( vtFormatContemporary, vtOptional, vtOptional,
vtOptional
, vtOptional, vtOptional, vtOptional, vtOptional, vtOptional,
vtOptional);

Cell oCellTitle = oTable.Cell(1,1);
oRange = oCellTitle.GetRange();

oMailMergeFields.Add(oRange, "RUBRIQUES");

// Creation and merging operation in the cells of the table
cellsOfTable( oTable, nb_lignes, oWord, oMailMergeFields);
</ end code merging of table>


Here is the code of the inserting of my image
<code image>
oRange = oSelection.GetRange();
oParagraphs = oRange.GetParagraphs();
oParagraph = oParagraphs.GetLast();
Range oTargetRange = oParagraph.GetRange();

VARIANT vTargetRange;
vTargetRange.vt = VT_DISPATCH;
vTargetRange.pdispVal = TargetRange.m_lpDispatch;

Shapes shapes = oDoc.GetShapes();
shapes.AddPicture("C:\\Documents and Settings\\Administrateur\\Mes
documents\\Mes images\\Matrix.jpg",
vtFalse, vtTrue , vtOptional, vtOptional, vtOptional, vtOptional,
&vTargetRange);
</code image>

here
<Code merging>
...
<end code merging>

the inserting of the image is placed after my merging tables whereas she
should be between the 2 tables. Why?
In advance, thanks.
 
C

Cindy M -WordMVP-

Hi Neonico,

In case you hadn't noticed, this is a newsgroup for end-user questions.
Programming questions belong in an office.developer or word.vba newsgroup.
the inserting of the image is placed after my merging tables whereas she
should be between the 2 tables. Why?
It's not very clear what your code is doing. Using Selection is always a
bit chancy, as well as difficult to follow. You should avoid it... My best
guess is this:

oParagraph = oParagraphs.GetLast();
Range oTargetRange = oParagraph.GetRange();

If you have two tables, what stands between the two tables? Is there
anything between the two tables? Generally, if I want to move directly
beneath a table, I do something like this (VB code)

Dim tbl as Word.Table
Dim rng as Word.Range
Set tbl = doc.Tables(1)
Set rng = tbl.Range
'Go beneath the table
rng.Collapse Direction:=wdCollapseEnd

Cindy Meister
INTER-Solutions, Switzerland
http://homepage.swissonline.ch/cindymeister (last update Jun 8 2004)
http://www.word.mvps.org

This reply is posted in the Newsgroup; please post any follow question or
reply in the newsgroup and not by e-mail :)
 

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