Re: How do I make mass format changes to mail merge fields?

Tech-Archive recommends: Fix windows errors by optimizing your registry



Are you in a position to create views in SQL Server that convert the float fields to formatted text fields, then use those views as the data sources for your merge? Then you may be able to avoid this step altogether - e.g. a Transact-SQL formula such as

'$'+convert(varchar,cast(round(UnitPrice,2) as money),1) [UnitPrice]

should convert a float value to a suitable $ value with comma separators.

Peter Jamieson

http://tips.pjmsn.me.uk

Jef Bray wrote:
I have several MS Word documents that contain a high concentration of merge fields (each document has upwards of 80-150 merge fields).

As experienced mail-merge users already know, formatting is not retained from the data source, so I am expected to provide formatting instructions via merge field "switches" such as \# $#,###.00 right within the merge field code itself. This is fine for documents with just a few fields to adjust, but I'm looking at hundreds and hundreds of fields here.

My problem is that typing formatting switches into each individual merge field, one at a time, is very labour-intensive for documents such as mine. Is there a way to apply these switches en-masse or perform some sort of search & replace, taking merge field code into account?

It just seems very odd to me that a mature product such as MS Word butchers decimal numbers so horribly (e.g. 40.1 is expressed as either 40.09999999999999 or as 40.10000000000000000001) and provide no way of formatting these, except individually & manually.

Thanks in advance for any help you can provide.

ps: I am using SQL Server as a datasource, not that this should matter. The datatype of the fields in question is "float"
.



Relevant Pages

  • Re: Lining up with page edge.
    ... (The contextual selectors are only for ease of later ... > float: right; ... much less formatting stuff in the markup - in fact no formatting stuff ... in the markup - which is the way CSS is supposed to work. ...
    (comp.infosystems.www.authoring.stylesheets)
  • Re: How do I format a float number?
    ... If you do not want to return a string, then you don't need to do anything ... with formatting. ... A float is a 32-bit binary number. ... HTH, ...
    (microsoft.public.dotnet.framework)
  • Re: Addition error in DotNet 2.0
    ... I think you'll find that the default formatting is leading you astray. ... Try the following in a console app: ... float e = 0.1f; ...
    (microsoft.public.dotnet.framework)
  • Re: how to stop variable rounding up after a division
    ... You can try forcing a cast to float, ... The second example is not formatting the fraction, so it is printed in default format. ...
    (comp.lang.php)
  • Re: Set based solution
    ... And SQL IS a data manipulation language, hence my problem with not using it ... that I had always used SQL Server to do data formatting for the past 12 ... instead of coding hooks in a dll to do this formatting, ... SQL, and T-SQL, is not a general purpose programming language. ...
    (microsoft.public.sqlserver.programming)