Ureader.com  
Microsoft software help and Community
   home   |   control panel login   |   archive   |  
 
Word
application.errors
conversions
docmanagement
drawing.graphics
formatting.longdocs
international
internet.assistant
mail
mailmerge.fields
menustoolbars
newusers
numbering
oleinterop
pagelayout
printingfonts
setup.networking
spelling.grammar
tables
vba.addins
vba.beginners
vba.customization
vba.general
vba.userforms
web.authoring
word6-7macros
word97vba
  
 
date: Wed, 7 Nov 2007 14:30:01 -0800,    group: microsoft.public.word.oleinterop        back       


Word Late Binding with C#   
I haven't been able to find much help on this topic anywhere.  I am hoping I 
can find it here.

I have developed an application, amongst other things,  that opens a word 
doc, grabs the collection of bookmarks found, returns them to the user and 
allows the user to modify their values and save the new documents off.  I 
have done all of this by using late binding techniques.  The following code 
snippet will illustrate this routine:

//Bookmarks
                object mBookmarks = 
iDI.objDoc.GetType().InvokeMember("Bookmarks",
                                    BindingFlags.GetProperty, null, 
iDI.objDoc,
                                    new object[] { });

                iDI.objBookmarks = mBookmarks;//Bookmarks object used to 
collect each Bookmark object

                string wBookmark = "";
                foreach (object bk in mBookmarks as IEnumerable)
                {
                    //Name
                    wBookmark = (string)bk.GetType().InvokeMember("Name",
                                        BindingFlags.GetProperty, null, bk,
                                        new object[] { });

                    iDI.BookMarkInfo.Add(wBookmark);
                }
                //Marshal.ReleaseComObject(wDI.objDoc);
                iDI.objDoc.GetType().InvokeMember("Close", 
BindingFlags.InvokeMethod, null, iDI.objDoc, null);
                listDocInfo.Add(iDI);//Add docinfo object to list
                return iDI.BookMarkInfo;//return list of bookmarks


All of this works great.  I have another routine that will allow me to write 
out to the bookmarks as well.  However, I now need to do the same thing but 
with Fields and MergeFields.  I am able to create the Fields collection.  
However, after that, I am not familiar with the metadata and I can't seem to 
find any documentation in regards to it. 

So, to sum things up, I simply need to retrieve all of the MergeFields in a 
document and write to these fields within a new document and save it off. 

Any help would be much appreciated.  Thanks.

-- 
PD
date: Wed, 7 Nov 2007 14:30:01 -0800   author:   Playmaker81

Google
 
Web ureader.com


    COPYRIGHT 2007, YARDI TECHNOLOGY LIMITED, ALL RIGHT RESERVE  |   contact us