Click here to Skip to main content
14,578,986 members
Rate this:
Please Sign up or sign in to vote.
See more:
hi i was try below code for Embedding a Document in word but i get error message like==
"The requested member of the collection does not exist." my word file not blank any idea why i am getting this error any idea what i am done wrong please help me to solve the issue




//ICON LABEL CAN BE THE NAME OF THE FILE,

           //ITS THE NAME DISPLAYED BESIDES THE EMBEDDED DOCUMENT

           Object oIconLabel = "File Name";



           //INCASE WE NEED THE EMBEDDED DOCUMENT TO BE DISPLAYED AS A SPECIFIC ICON,

           //WE NEED TO SPECIFY THE LOCATION OF THE ICON FILE

           //ELSE SET IT TO oMissing VALUE

           Object oIconFileName = "C:\\IconFile.ico";


           //THE BOOKMARK WHERE THE FILE NEEDS TO BE EMBEDDED

           Object oBookMark = "My_Custom_BookMark";

           //THE LOCATION OF THE FILE

           Object oFileDesignInfo = "C:\\1.doc";






           //METHOD TO EMBED THE DOCUMENT

           oWordDoc.Bookmarks.get_Item(ref oBookMark).Range.InlineShapes.AddOLEObject(ref oClassType, ref oFileDesignInfo, ref oFalse, ref oTrue, ref oIconFileName,

               ref oMissing, ref oIconLabel, ref oMissing);
Posted
Updated 28-Oct-13 21:58pm
v2

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)




CodeProject, 503-250 Ferrand Drive Toronto Ontario, M3C 3G8 Canada +1 416-849-8900 x 100