How to check a checkbox in MS Word?

GaryD
Member Posts: 66
Hello all. In Nav 5.1, we're using automation to populate form fields in a Word 2007 document. We've got the following working for text fields:
WRange := WDoc.Fields.Item(11).Result;
WRange.Text := Sellto."No.";
but I'm not sure of how to check/uncheck a checkbox.
Also, are there any good tutorials or articles out there that cover programming MS Office in NAV?
Thanks!
WRange := WDoc.Fields.Item(11).Result;
WRange.Text := Sellto."No.";
but I'm not sure of how to check/uncheck a checkbox.
Also, are there any good tutorials or articles out there that cover programming MS Office in NAV?
Thanks!
0
Comments
-
Do you mean other that waht's in the application designers guide?
Which has sections on MS word & Excel automation.
As for the check box - do you want to update a check box in nav or show a check box in word?0 -
Savatage, yes, other than the application designers guide. It seemed kind of light on the automation coverage. It covered automation of text values but not things like radio buttons, checkboxes, images, manipulating Word tables by adding columns and rows, etc...
Some of this I've learned already but haven't had the need to update checkboxes until now. I'll restate my issue:
I have a boolean value in my database, which corresponds to a checkbox in a Word document. In NAV a user clicks a button and NAV opens up the Word document and pre-populates a bunch of the form fields on it. I know how to update the document's text fields but I don't know how to update a checkbox. The checkbox already exists on the Word document, I just want NAV to be able to check it or uncheck it when the document loads, based upon the value of the database field. I'd just like the equivelent of what I do with the textbox when I do:
WRange := WDoc.Fields.Item(11).Result;
WRange.Text := Sellto."No.";
which is populating the Word text field with the content of "No." field from the Customer table.
Thanks!0 -
I agree the Office Automation in the ADG isn't very detailed. And lots of trial & error. ](*,)
When I need a checkbox in Word I use the old Capital "R" with font "Wingdings 2" I don't know if that will help in anyway.0 -
Thanks Savatage but that won't work. The checkbox in the Word document is an actual checkbox. It can only be checked or unchecked. I can't put anything else into it. And as the form is also used outside of NAV, I can't redesign it to use your suggestion.0
-
One more piece of info that I found out. Looking in MSDN for the FormField object, this is how you change the value of a checkbox:
ActiveDocument.FormFields("Check1").CheckBox.Value = True
I don't know if there's a difference between formfields and fields but for count they both returned the number of fields on the document. I've tried coding for each with no success.
I can do this:
message(format(wdoc.formfields.count)); // or wdoc.fields.count
which seems to give me the correct number of fields in the Word document. But perhaps the object library that NAV has access to is stripped down or something because none of the following work
message(format(wdoc.fields.item(23).result)); // returns "In use"
message(format(wdoc.formfields.item(23).result)); // returns "A variable was expected" for item(23)
message(format(wdoc.fields(23).result)); // compiling returns "A max of 0 parameters must be used..."
message(format(wdoc.Fields.item(23).checkbox.value));
// compiling returns "You have specified an unknown variable" (for checkbox)
message(wdoc.formfields.item(21).value); // returns "A variable was expected" for the item(21)
message(wdoc.formfields.item("Check21").value);
// returns "a variable was expected" for the "Check21" Word bookmark name
Bottom line is that formfields.count returns the correct count so I must have accessed the collection but I just can't figure out how to dig down into it to get what I want.0
Categories
- All Categories
- 73 General
- 73 Announcements
- 66.6K Microsoft Dynamics NAV
- 18.7K NAV Three Tier
- 38.4K NAV/Navision Classic Client
- 3.6K Navision Attain
- 2.4K Navision Financials
- 116 Navision DOS
- 851 Navision e-Commerce
- 1K NAV Tips & Tricks
- 772 NAV Dutch speaking only
- 617 NAV Courses, Exams & Certification
- 2K Microsoft Dynamics-Other
- 1.5K Dynamics AX
- 320 Dynamics CRM
- 111 Dynamics GP
- 10 Dynamics SL
- 1.5K Other
- 990 SQL General
- 383 SQL Performance
- 34 SQL Tips & Tricks
- 35 Design Patterns (General & Best Practices)
- 1 Architectural Patterns
- 10 Design Patterns
- 5 Implementation Patterns
- 53 3rd Party Products, Services & Events
- 1.6K General
- 1.1K General Chat
- 1.6K Website
- 83 Testing
- 1.2K Download section
- 23 How Tos section
- 252 Feedback
- 12 NAV TechDays 2013 Sessions
- 13 NAV TechDays 2012 Sessions