.net - C# check merge field check box in a word document -
just wondering how check check box on word document, have c# window forms application filling in merge fields data obtained forms such textboxes , comboboxes. though wondering how check text box in c#?
i have been trying find awhile now, , have resulted in asking question here.
the code below how connect word document , fill out merge field on document.
object omissing = system.reflection.missing.value; object otrue = true; object ofalse = false; word.application oword = new word.application(); word.document oworddoc = new word.document(); oword.visible = true; if (file.exists("pathname.txt")) { filestream file = new filestream("pathname.txt", filemode.open, fileaccess.read); streamreader reader = new streamreader(file); pathname = reader.readline(); } object otemplatepath = pathname; oworddoc = oword.documents.add(ref otemplatepath, ref omissing, ref omissing, ref omissing); foreach (word.field mymergefield in oworddoc.fields) { itotalfields++; word.range rngfieldcode = mymergefield.code; string fieldtext = rngfieldcode.text; if (fieldtext.startswith(" mergefield")) { int32 endmerge = fieldtext.indexof("\\"); int32 fieldnamelength = fieldtext.length - endmerge; string fieldname = fieldtext.substring(11, endmerge - 11); fieldname = fieldname.trim(); if (fieldname == "name") { mymergefield.select(); oword.selection.typetext(firstname.text); } if (fieldname == "name2") { mymergefield.select(); oword.selection.typetext(textbox6.text); } if (fieldname == "lastname1") { mymergefield.select(); oword.selection.typetext(textbox3.text); } }
any appreciated.
thank you.
Comments
Post a Comment