Add fields as text

J

Juan

Hi everyone,

in my C# app to generate Word documents I am able now, with help from people
from this group, to generate the tables where I want them, and in the style
I want them.

Populate them is not hard, I do it from an array that is passed to the table
as a parameter, but... sometimes, the value of a cell must be a DocProperty,
or a formula (based on calculations from two DocProperties).

I only know how to insert field such as DocProperty by calling the
Fields.Add procedure, but is not the way to go in this case.

Is there a way to add the fields as string of text that words understands
and translates as a property?

Thanks, from Spain

Juan Magaña
 
D

Doug Robbins - Word MVP - DELETE UPPERCASE CHARACT

Hi Juan,

I would use Document Variables instead of CustomDocumentProperties, and then
just insert the .Value of the variable or the result of a calculation based
on the .Values of the contributing Variables.

Please post any further questions or followup to the newsgroups for the
benefit of others who may be interested. Unsolicited questions forwarded
directly to me will only be answered on a paid consulting basis.

Hope this helps
Doug Robbins - Word MVP
 
J

Juan

Really, the way I need to do it doesn´t matter if it´s a CustomProperty or a
document variable. I need to assign the text to a cell of a table to look
something like

{DOCPROPERTY */ PAX}

but, of course, if I do it just like that Word won´t see it as a field.


"Doug Robbins - Word MVP - DELETE UPPERCASE CHARACTERS FROM EMAIL ADDRESS"
 
D

Doug Robbins - Word MVP - DELETE UPPERCASE CHARACT

Hi Juan,

On the assumption that your application is producing the final documents, I
am not sure why you are inserting fields such as that rather than directly
inserting the values assigned to the property or variable.

I have looked back through the several threads that you have posted to this
newsgroup, but am not able to tell exactly what it is that you are doing.
Perhaps if you can give us an overall picture of what you want to
accomplish, we can give you better advice than when we just see parts of the
problem.

Please post any further questions or followup to the newsgroups for the
benefit of others who may be interested. Unsolicited questions forwarded
directly to me will only be answered on a paid consulting basis.

Hope this helps
Doug Robbins - Word MVP
 
J

Juan

Hi Doug,

as you say, it's a lot easier and simpler to just add the value as I build
the table.

The application generates several Word documents, which are different quotes
for a service, and a final document with a table indicating items and
prices. Those prices are easily calculated by a formula based in some values
that are DocProperties. Of course, I can calculate the values more easily in
the program, but the client insisted (not anymore, thankfully) on having
those calculations as formula fields in the table so that if he chose to
change, once the document is generated, a DocProperty (one in particular
that I added which affects all the formulas) all the values would be
updated.

If that´s not possible at all, it doesn´t really matter since, as you say,
it´s easier to calculate in my C# app and just insert the resulting value in
the correspondent cell as I build it.

I hope I helped you understand what I tried to acomplish.

Thanks again for your help.

From Spain,

Juan


"Doug Robbins - Word MVP - DELETE UPPERCASE CHARACTERS FROM EMAIL ADDRESS"
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top