Click here to Skip to main content
15,922,166 members
Home / Discussions / C#
   

C#

 
QuestionCombo Box and refresh/reload data Pin
Saamir19-Jun-06 7:45
Saamir19-Jun-06 7:45 
AnswerRe: Combo Box and refresh/reload data Pin
Paul Brower19-Jun-06 9:31
Paul Brower19-Jun-06 9:31 
QuestionRe: Combo Box and refresh/reload data Pin
Saamir19-Jun-06 10:14
Saamir19-Jun-06 10:14 
GeneralRe: Combo Box and refresh/reload data Pin
Saamir20-Jun-06 5:16
Saamir20-Jun-06 5:16 
QuestionHow to Count number of specific day Pin
rockxuyenmandem19-Jun-06 7:36
rockxuyenmandem19-Jun-06 7:36 
AnswerRe: How to Count number of specific day Pin
LongRange.Shooter19-Jun-06 7:51
LongRange.Shooter19-Jun-06 7:51 
AnswerRe: How to Count number of specific day Pin
Tom Delany20-Jun-06 4:49
Tom Delany20-Jun-06 4:49 
QuestionAutomating Word to Fill in a Word Template Pin
vnoga19-Jun-06 7:34
vnoga19-Jun-06 7:34 
For testing purposes, I created a simple Word 2003 Template with 2 fields. I then set the protection level to "Filling in Forms". The template itself is fine and works as expected within Word. In other words, when I open the template in Word, I am presented with a new document in which I can only enter values in the two supplied fields and save the document.

Also for testing purposes, I wrote a C# app to automate filling in my sample template. In my C# app, I start word, open the template, find a field, and attempt to enter a value.

object bookmark = "Text1";
Word.Bookmark myBookmark = myWordTemplate.Bookmarks.get_Item(ref bookmark);
myBookmark.Select();
myBookmark.Range.Text = "Hello";


Upon trying to assign a value to the field, I get an exception stating the value can't be changed because protection is enabled. Since the protection level is set to "Filling in Forms", does anyone have any idea why this exception is being thrown? Or is the above not the proper way to fill fields defined in a word template?

Last, please note that if (in my code) I disable protection, write my value, re-enable protection, and save the document, my code works but with the following unwanted side effects:

- Within my C# app, the field/bookmark object gets overwritten/deleted, as in it gets deleted from the field/bookmark collection.

- My first comment is confirmed by opening the resulting document in Word -- any field to which I assigned a value (in code) is no longer there. The value I wrote is there and in the proper place, but the template itself is basically destroyed. In other words, when I automate filling in the form, the user isn't able to open the resulting document and make any changes like they could if they manually filled in the form with Word.


Any suggestion or workaround would be appreciated.




Vince
AnswerRe: Automating Word to Fill in a Word Template Pin
vnoga19-Jun-06 8:14
vnoga19-Jun-06 8:14 
QuestionTextarea - Multiple data submission Pin
edgtr19-Jun-06 5:59
edgtr19-Jun-06 5:59 
AnswerRe: Textarea - Multiple data submission Pin
LongRange.Shooter19-Jun-06 7:58
LongRange.Shooter19-Jun-06 7:58 
Questionclass to be both marked with the serializable attribute and extend MarshalByRefObject [modified] Pin
Kiran Kumar Singani19-Jun-06 3:14
Kiran Kumar Singani19-Jun-06 3:14 
AnswerRe: class to be both marked with the serializable attribute and extend MarshalByRefObject Pin
Josh Smith19-Jun-06 4:03
Josh Smith19-Jun-06 4:03 
QuestionLooking for C# programming practice questions Pin
antoan19-Jun-06 3:04
antoan19-Jun-06 3:04 
AnswerRe: Looking for C# programming practice questions Pin
Josh Smith19-Jun-06 3:30
Josh Smith19-Jun-06 3:30 
AnswerRe: Looking for C# programming practice questions Pin
Colin Angus Mackay19-Jun-06 4:04
Colin Angus Mackay19-Jun-06 4:04 
GeneralRe: Looking for C# programming practice questions Pin
Josh Smith19-Jun-06 4:30
Josh Smith19-Jun-06 4:30 
GeneralRe: Looking for C# programming practice questions Pin
leckey19-Jun-06 5:12
leckey19-Jun-06 5:12 
AnswerRe: Looking for C# programming practice questions Pin
Daniel Persson19-Jun-06 4:25
Daniel Persson19-Jun-06 4:25 
AnswerRe: Looking for C# programming practice questions Pin
Drew McGhie19-Jun-06 7:27
Drew McGhie19-Jun-06 7:27 
Questionhow to delete entries in HKLM of windows registry Pin
YogeshRT19-Jun-06 2:24
YogeshRT19-Jun-06 2:24 
AnswerRe: how to delete entries in HKLM of windows registry Pin
leppie19-Jun-06 2:56
leppie19-Jun-06 2:56 
QuestionScrolling an image Pin
rheia8419-Jun-06 2:08
rheia8419-Jun-06 2:08 
AnswerRe: Scrolling an image Pin
Judah Gabriel Himango19-Jun-06 6:05
sponsorJudah Gabriel Himango19-Jun-06 6:05 
GeneralRe: Scrolling an image Pin
rheia8420-Jun-06 3:52
rheia8420-Jun-06 3:52 

General General    News News    Suggestion Suggestion    Question Question    Bug Bug    Answer Answer    Joke Joke    Praise Praise    Rant Rant    Admin Admin   

Use Ctrl+Left/Right to switch messages, Ctrl+Up/Down to switch threads, Ctrl+Shift+Left/Right to switch pages.