Hi ,
I'm trying to insert a word file F1 into a word file F2 using the
following instruction :
Object trueValue = true;
Object falseValue = false;
Object oEndOfDoc = "\\endofdoc";
Microsoft.Office.Interop.Word.Document nvDoc;
nvDoc.Bookmarks.get_Item(ref
oEndOfDoc).Range.InsertFile((string)fileName, ref missing, ref missing,
ref falseValue, ref trueValue);
But the result I get is that the F1's content is inserted at the end of
F2 file .
I want F1 to show up in F2 as an icon, like an attached file, and I
want to be able to delete F1 from the disk so that the only way to
access it is to open F2 and click on the F1 icon.
Someone can help me ?
Thanks
Cindy M -WordMVP- - 26 Jul 2006 14:38 GMT
> I'm trying to insert a word file F1 into a word file F2 using the
> following instruction :
[quoted text clipped - 13 lines]
> want to be able to delete F1 from the disk so that the only way to
> access it is to open F2 and click on the F1 icon.
You're using the wrong method :-) What you want to do is embed the F2 in
F1, and for that you need something more like this (recorded VBA):
Selection.InlineShapes.AddOLEObject ClassType:="Word.Document.8",
FileName _
:="C:\Documents and Settings\[ProfileName]\My
Documents\bug2.doc", _
LinkToFile:=False, DisplayAsIcon:=True, IconFileName:= _
"C:\WINDOWS\Installer\{00000409-78E1-11D2-B60F-006097C998E7}\wordicon.exe
" _
, IconIndex:=1, IconLabel:= _
"C:\Documents and Settings\Cindy Meister\My Documents\bug2.doc"
Of course, you use a range instead of Selection. And you can probably get
away with passing "Missing" to the IconFileName and IconIndex
parameters, if you want.
-- Cindy