Home | Contact Us | FAQ | Search & Site Map | Link to Us
Sign In | Join | Other 45 Sites in Network
HomeAnnouncementsFree MagazinesWhite PapersSubmit Content
Discussion GroupsASP.NETWindows FormsLanguages.NET FrameworkVisual Studio.NET
Articles.NET FrameworkASP.NETToolsWindows Forms
.NET DirectoryOpen Source ProjectsUser GroupsWeb Resources
Related Topics
Visual Basic 6SQL ServerMS AccessOther DB ProductsMS Server ProductsMore Topics ...

.NET Forum / .NET Framework / Interop / July 2006

Tip: Looking for answers? Try searching our database.

How to insert a word file in another word file as an attachment ?

Thread view: 
Enable EMail Alerts  Start New Thread
Thread rating: 
catherine.trojanowski@gmail.com - 17 Jul 2006 16:35 GMT
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

Rate this thread:







Free Magazines

Get these publications absolutely FREE for up to 12 months. There are no hidden fees and no obligation. Simply choose a title, complete the application form and submit it. Read more ...

Oracle MagazineNetwork ComputingComputer WorldBio-IT WorldeWeekInformation WeekInfosecurity
 
Sign In
Join
My Latest Posts
My Monitored Threads
My Blog
My Photo Gallery
My Profile
My Homepage

Start New Thread
Enable EMail Alerts
Rate this Thread



©2008 Advenet LLC   Privacy Policy - Terms of Use
This website includes both content owned or controlled by Advenet as well as content owned or controlled by third parties.