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!
0
Comments
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?
http://www.BiloBeauty.com
http://www.autismspeaks.org
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!
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.
http://www.BiloBeauty.com
http://www.autismspeaks.org
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.