Formatting Date fields

G

Greg

Is there any way to use VBA to format date fields, bypassing the "\@" word
switch.

What I want to do is develop a date format that will take a standard date
and convert it to its hebrew calander equivalent while merging a document.

--
Gregory M. La Due
Twin Tiers Technologies, Inc.
Senior Programmer
(e-mail address removed)
(800) 480-6467
 
P

Peter Jamieson

There are a few ways you could approach this, depending on how simple the
conversion algorithm is.

First, I would want to be sure that using a Hebrew-language enabled version
of Word would not let you do it. If it can, that might be your best bet.

You may be able to do the calculation in the data source (might be possible
if for example you are using a server such as SQl Server or Oracle, or can
use an Access Query. In the latter case, the algorithm either needs to be
expressible in a single VBA function that you can put in a query, or you
need to write a function in Access VBA module, reference it in an Access
query, and use the DDE connection method to open the data source).

If the algorithm requires no looping you might be able to do it just using
field calculations. macropod's Word document at

http://www.wopr.com/cgi-bin/w3t/showthreaded.pl?Number=249902

has pointers on how to do that although I don't think it currently has code
to do exactly what you need.

Again, if the algorithm can be expressed in a single, reasonably short, VBA
expression, you might be able to use a DATABASE field in Word to do the
calculation. If you search google groups for recent messages in this group
with Peter Jamieson DATABASE, you will probably find an article on how to do
that.

Otherwise, you would need either to merge to an output document and
postprocess all the dates using VBA (in which case you need some way to
locate the dates, e.g. using "placehoder" characters, or you need to use VBA
MailMerge events to do the calculation for each data source record.

Peter Jamieson

Otherwise, you will
 
G

Graham Mayor

Just a thought, as I know nothing about the calculations involved in
converting between the dates, it may be possible to adapt the methods used
to convert between Gregorian and Julian dates explained at
www.wopr.com/cgi-bin/w3t/showthreaded.pl?Number=249902 to enable you to use
fields. If you know the mathematics involved this may help.

--
<>>< ><<> ><<> <>>< ><<> <>>< <>><<>
Graham Mayor - Word MVP


<>>< ><<> ><<> <>>< ><<> <>>< <>><<>
 
M

macropod

Hi Greg,

If you merge the date as a purely numeric string (eg ddmmyyyy), you could
use vba to format the output with a numeric picture switch. For example:
\# "00'-'00'-'0000"
This will give a pseudo-numeric representation of the date.

If, however, you're trying to get away from switches altogether, and you're
not happy with the date format you get using no switches, I think you're
going to have to use a purely vba solution to format the date as you require
and paste it into the document as normal text.

Cheers
 
G

Graham Mayor

I was afraid that might be the case, but thought you might have been tempted
by the challenge ;)

--
<>>< ><<> ><<> <>>< ><<> <>>< <>><<>
Graham Mayor - Word MVP


<>>< ><<> ><<> <>>< ><<> <>>< <>><<>
 

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