Home | Contact Us | FAQ | Search & Site Map | Link to Us
Sign In | Join | Other 45 Sites in Network
Home
DiscussionsAccessExcelInfoPathOutlookPowerPointPublisherWord
DirectoryUser Groups
Related Topics
Outlook ExpressInternet ExplorerWindowsMS Server ProductsMore Topics ...

MS Office Forum / Word / Mailmerge and Fax / July 2004

Tip: Looking for answers? Try searching our database.

How to format mergefield dates and numbers within VBA code

Thread view: 
Enable EMail Alerts  Start New Thread
Thread rating: 
Philip Lages - 02 Jul 2004 09:12 GMT
Hi,

I use this code to insert mergefields filled by an Access DB  into a
document .

ActiveDocument.FormFields("txtWerkNaam").Select
ActiveDocument.MailMerge.Fields.Add Range:=Selection.Range,
Name:="naam_werk"

This works fine but the contents of the date fields are formatted dd/MM/yyy
H/mm/ss
I don't want to disply the time in my document.
How can i format mergefields in VBA

Any help appreciated

Philip Lages
Doug Robbins - 03 Jul 2004 22:32 GMT
Hi Philip,

Use the following code to insert the mergefield with a formatting switch:

Dim myrange As Range
Set myrange = ActiveDocument.FormFields("txtWerkNaam").Range
ActiveDocument.Fields.Add Range:=myrange, Type:=wdFieldEmpty,
Text:="mergefield txtWerkNaam \@ ""dd MM yyyy"""

Signature

Please respond to the Newsgroup for the benefit of others who may be
interested.   Questions sent directly to me will only be answered on a paid
consulting basis.

Hope this helps,
Doug Robbins - Word MVP

> Hi,
>
[quoted text clipped - 13 lines]
>
> Philip Lages
Philip Lages - 05 Jul 2004 11:05 GMT
Thanks Doug this works perfectly

Philip Lages

> Hi Philip,
>
[quoted text clipped - 23 lines]
> >
> > Philip Lages

Rate this thread:






 
Sign In
Join
My Latest Posts
My Monitored Threads
My Blog
My Photo Gallery
My Profile
My Homepage

Start New Thread
Enable EMail Alerts
Rate this Thread



©2008 Advenet LLC   Privacy Policy - Terms of Use
This website includes both content owned or controlled by Advenet as well as content owned or controlled by third parties.