Reply
 
Thread Tools Display Modes
  #1   Report Post  
Posted to microsoft.public.word.mailmerge.fields
Peter Hibbs[_2_] Peter Hibbs[_2_] is offline
external usenet poster
 
Posts: 19
Default Mail Merge Format Text String

I am using Access 2003 to create a mail merge document using
Automation. For reasons too complicated to explain here I have a Memo
field (plus a number of other fields) in an Access table which will be
the source data for the mail merge. The Memo field will contain
between one and 20 lines of text.

What I would like is to have the ability to add some rudimentary
formatting to the various lines of text in this field. The problem is
that, at the moment, any formatting done to the field affects all the
text in the field - all bold, all italics, etc. What I need is to
allow the user to enter some sort of control code in the text which
would then enable/disable formatting.

For example, if I had something like this in the Memo field :-

This is normal text [b] this is bold [b] this is normal.

then Word would change the [b] character sequence into the equivalent
of ^B and show the text between them in bold. I don't need anything
more fancy then that, bold, italics and underline would suffice.

Is there any way to add some sort of If-Then-Else control codes in the
mail merge field which could check the string and apply the
appropriate formatting.

Peter Hibbs.
  #2   Report Post  
Posted to microsoft.public.word.mailmerge.fields
macropod[_2_] macropod[_2_] is offline
external usenet poster
 
Posts: 2,059
Default Mail Merge Format Text String

Hi Peter,

What you're asking can't be done that way. If you need parts of your text to have different formatting, those parts need to be in
separate fields in your data source. Alternatively, if you add suitable tags to your data field (as it seems you're prepared to do),
you could use a macro after running the merge to find the tags, remove them and re-format the intervening text as desired.

--
Cheers
macropod
[MVP - Microsoft Word]


"Peter Hibbs" wrote in message ...
I am using Access 2003 to create a mail merge document using
Automation. For reasons too complicated to explain here I have a Memo
field (plus a number of other fields) in an Access table which will be
the source data for the mail merge. The Memo field will contain
between one and 20 lines of text.

What I would like is to have the ability to add some rudimentary
formatting to the various lines of text in this field. The problem is
that, at the moment, any formatting done to the field affects all the
text in the field - all bold, all italics, etc. What I need is to
allow the user to enter some sort of control code in the text which
would then enable/disable formatting.

For example, if I had something like this in the Memo field :-

This is normal text [b] this is bold [b] this is normal.

then Word would change the [b] character sequence into the equivalent
of ^B and show the text between them in bold. I don't need anything
more fancy then that, bold, italics and underline would suffice.

Is there any way to add some sort of If-Then-Else control codes in the
mail merge field which could check the string and apply the
appropriate formatting.

Peter Hibbs.


  #3   Report Post  
Posted to microsoft.public.word.mailmerge.fields
Peter Hibbs[_2_] Peter Hibbs[_2_] is offline
external usenet poster
 
Posts: 19
Default Mail Merge Format Text String

Hi macropod,

I had suspected as much. I will look into your suggestion about
formatting after the merge, it may be possible to do this from Access
using Automation (I am more comfortable writing VBA code than Macros),
also I am trying to make things as easy for the end user as possible,
i.e. avoid them having to add a Macro to each new Word document they
create.

Anyway, thanks again for your thoughts.

Peter Hibbs.

On Mon, 23 Feb 2009 07:54:44 +1100, "macropod"
wrote:

Hi Peter,

What you're asking can't be done that way. If you need parts of your text to have different formatting, those parts need to be in
separate fields in your data source. Alternatively, if you add suitable tags to your data field (as it seems you're prepared to do),
you could use a macro after running the merge to find the tags, remove them and re-format the intervening text as desired.

  #4   Report Post  
Posted to microsoft.public.word.mailmerge.fields
macropod[_2_] macropod[_2_] is offline
external usenet poster
 
Posts: 2,059
Default Mail Merge Format Text String

Hi Peter,

I am more comfortable writing VBA code than Macros

Huh? vba = macro.

--
Cheers
macropod
[MVP - Microsoft Word]


"Peter Hibbs" wrote in message ...
Hi macropod,

I had suspected as much. I will look into your suggestion about
formatting after the merge, it may be possible to do this from Access
using Automation (I am more comfortable writing VBA code than Macros),
also I am trying to make things as easy for the end user as possible,
i.e. avoid them having to add a Macro to each new Word document they
create.

Anyway, thanks again for your thoughts.

Peter Hibbs.

On Mon, 23 Feb 2009 07:54:44 +1100, "macropod"
wrote:

Hi Peter,

What you're asking can't be done that way. If you need parts of your text to have different formatting, those parts need to be in
separate fields in your data source. Alternatively, if you add suitable tags to your data field (as it seems you're prepared to
do),
you could use a macro after running the merge to find the tags, remove them and re-format the intervening text as desired.


  #5   Report Post  
Posted to microsoft.public.word.mailmerge.fields
Peter Jamieson Peter Jamieson is offline
external usenet poster
 
Posts: 4,582
Default Mail Merge Format Text String

In Access, you have those older "macros" (i.e. not VBA), and VBA.

In Word, there's just VBA, and things written in it are typically called
"macros."

Peter Jamieson

http://tips.pjmsn.me.uk

Peter Hibbs wrote:
Hi macropod,

I had suspected as much. I will look into your suggestion about
formatting after the merge, it may be possible to do this from Access
using Automation (I am more comfortable writing VBA code than Macros),
also I am trying to make things as easy for the end user as possible,
i.e. avoid them having to add a Macro to each new Word document they
create.

Anyway, thanks again for your thoughts.

Peter Hibbs.

On Mon, 23 Feb 2009 07:54:44 +1100, "macropod"
wrote:

Hi Peter,

What you're asking can't be done that way. If you need parts of your text to have different formatting, those parts need to be in
separate fields in your data source. Alternatively, if you add suitable tags to your data field (as it seems you're prepared to do),
you could use a macro after running the merge to find the tags, remove them and re-format the intervening text as desired.



  #6   Report Post  
Posted to microsoft.public.word.mailmerge.fields
Peter Hibbs[_2_] Peter Hibbs[_2_] is offline
external usenet poster
 
Posts: 19
Default Mail Merge Format Text String

Hi macropod and Peter,

Yes, I am aware that, in Word, a Macro IS VBA, in the past I have
created a Macro and then looked at the VBA it created. What I really
meant was that I am more familiar with Access VBA than all the Word
commands and functions (although I have used the mail merge commands,
of course, in my Access code that creates the mail merge documents).

Anyway, back to the problem in hand. Having thought about it some
more I think it would be quite tricky using Automation code from
within Access to process the mail merge document that Word creates, I
assume it creates it in memory somewhere until the user saves it to
disk.

I quite like the idea of creating a Word macro that could just scan
through the document and change the formatting between two embedded
characters that the user would not normally use in a document. As I
said before, I need to make it as easy as possible for the user so I
would like to avoid having them create the same macro every time they
make up a new mail merge document.

Is it possible, therefore, to create a template file which holds the
macro and then let them use the template to start a new mail merge
document. And perhaps they could have a new button/icon which they
could click on to run the macro once they have created the mail merge
document. Would the template macro and button be automatically copied
into the new mail merge document each time.

The other possiblity would be to add a macro to the Normal.dot file
but I don't really want this facility on every document they create,
only mail merge documents.

I haven't had time to try any of this yet but if you think it will
work I will have a go.

Thanks for any info.

Peter Hibbs.

On Mon, 23 Feb 2009 07:46:26 +0000, Peter Jamieson
wrote:

In Access, you have those older "macros" (i.e. not VBA), and VBA.

In Word, there's just VBA, and things written in it are typically called
"macros."

Peter Jamieson

http://tips.pjmsn.me.uk

Peter Hibbs wrote:
Hi macropod,

I had suspected as much. I will look into your suggestion about
formatting after the merge, it may be possible to do this from Access
using Automation (I am more comfortable writing VBA code than Macros),
also I am trying to make things as easy for the end user as possible,
i.e. avoid them having to add a Macro to each new Word document they
create.

Anyway, thanks again for your thoughts.

Peter Hibbs.

On Mon, 23 Feb 2009 07:54:44 +1100, "macropod"
wrote:

Hi Peter,

What you're asking can't be done that way. If you need parts of your text to have different formatting, those parts need to be in
separate fields in your data source. Alternatively, if you add suitable tags to your data field (as it seems you're prepared to do),
you could use a macro after running the merge to find the tags, remove them and re-format the intervening text as desired.

  #7   Report Post  
Posted to microsoft.public.word.mailmerge.fields
Doug Robbins - Word MVP on news.microsoft.com Doug Robbins - Word MVP on news.microsoft.com is offline
external usenet poster
 
Posts: 407
Default Mail Merge Format Text String

The mail merge main document can certainly be saved as a template and if the
macro, to perform the task of replacing the text within a couple of
formatting marks with formatted text, is stored in that template, it would
be available for use on any document created from the template. It would
however be necessary for the mail merge main document to remain open for the
macros in that template to be available for use on the document created by
execution of the mail merge.

An alternative of course would be to use the mailmerge events that are
available and incorporate the code to do the formatting into some code that
would run as the mailmerge is executed. For an example of the use of those
events, see the add-in for creating individual letters from a mail merge
main document that you can down load from fellow MVP Graham Mayor's website
at:

http://www.gmayor.com/individual_merge_letters.htm

I have to admit however, I am wondering whether what you are wanting to do
is not easier to do with an Access report.

--
Hope this helps.

Please reply to the newsgroup unless you wish to avail yourself of my
services on a paid consulting basis.

Doug Robbins - Word MVP, originally posted via msnews.microsoft.com

"Peter Hibbs" wrote in message
...
Hi macropod and Peter,

Yes, I am aware that, in Word, a Macro IS VBA, in the past I have
created a Macro and then looked at the VBA it created. What I really
meant was that I am more familiar with Access VBA than all the Word
commands and functions (although I have used the mail merge commands,
of course, in my Access code that creates the mail merge documents).

Anyway, back to the problem in hand. Having thought about it some
more I think it would be quite tricky using Automation code from
within Access to process the mail merge document that Word creates, I
assume it creates it in memory somewhere until the user saves it to
disk.

I quite like the idea of creating a Word macro that could just scan
through the document and change the formatting between two embedded
characters that the user would not normally use in a document. As I
said before, I need to make it as easy as possible for the user so I
would like to avoid having them create the same macro every time they
make up a new mail merge document.

Is it possible, therefore, to create a template file which holds the
macro and then let them use the template to start a new mail merge
document. And perhaps they could have a new button/icon which they
could click on to run the macro once they have created the mail merge
document. Would the template macro and button be automatically copied
into the new mail merge document each time.

The other possiblity would be to add a macro to the Normal.dot file
but I don't really want this facility on every document they create,
only mail merge documents.

I haven't had time to try any of this yet but if you think it will
work I will have a go.

Thanks for any info.

Peter Hibbs.

On Mon, 23 Feb 2009 07:46:26 +0000, Peter Jamieson
wrote:

In Access, you have those older "macros" (i.e. not VBA), and VBA.

In Word, there's just VBA, and things written in it are typically called
"macros."

Peter Jamieson

http://tips.pjmsn.me.uk

Peter Hibbs wrote:
Hi macropod,

I had suspected as much. I will look into your suggestion about
formatting after the merge, it may be possible to do this from Access
using Automation (I am more comfortable writing VBA code than Macros),
also I am trying to make things as easy for the end user as possible,
i.e. avoid them having to add a Macro to each new Word document they
create.

Anyway, thanks again for your thoughts.

Peter Hibbs.

On Mon, 23 Feb 2009 07:54:44 +1100, "macropod"
wrote:

Hi Peter,

What you're asking can't be done that way. If you need parts of your
text to have different formatting, those parts need to be in
separate fields in your data source. Alternatively, if you add suitable
tags to your data field (as it seems you're prepared to do),
you could use a macro after running the merge to find the tags, remove
them and re-format the intervening text as desired.



  #8   Report Post  
Posted to microsoft.public.word.mailmerge.fields
Peter Hibbs[_2_] Peter Hibbs[_2_] is offline
external usenet poster
 
Posts: 19
Default Mail Merge Format Text String

Doug,

I will look into using templates with an embedded macro to make the
formatting changes after the mail merge letter has been created.

Thanks for the Web site, that looks very interesting, I will need to
study it further and I will pass the URL on to my client.

As I mentioned in an earlier post, I am writing this database for a
client and they will only have a .mde file so they will not be able to
make any changes to any reports I supply. Doing this via Word has the
big advantage that they can design their letters exactly how they want
(and there could be dozens) whereas I would have to make any changes
they want to any reports.

I will see how I get on with the template idea and will come back with
more questions if I need to, thanks again for your help.

Peter Hibbs.

On Mon, 23 Feb 2009 20:46:32 +1000, "Doug Robbins - Word MVP on
news.microsoft.com" wrote:

The mail merge main document can certainly be saved as a template and if the
macro, to perform the task of replacing the text within a couple of
formatting marks with formatted text, is stored in that template, it would
be available for use on any document created from the template. It would
however be necessary for the mail merge main document to remain open for the
macros in that template to be available for use on the document created by
execution of the mail merge.

An alternative of course would be to use the mailmerge events that are
available and incorporate the code to do the formatting into some code that
would run as the mailmerge is executed. For an example of the use of those
events, see the add-in for creating individual letters from a mail merge
main document that you can down load from fellow MVP Graham Mayor's website
at:

http://www.gmayor.com/individual_merge_letters.htm

I have to admit however, I am wondering whether what you are wanting to do
is not easier to do with an Access report.

Reply
Thread Tools
Display Modes

Posting Rules

Smilies are On
[IMG] code is On
HTML code is Off

Forum Jump

Similar Threads
Thread Thread Starter Forum Replies Last Post
How do I format Mail Merge doc to pick up currency format from Exc MamaSherry Mailmerge 2 December 19th 08 04:46 PM
Edit SQL String in Mail Merge Epoh Rio Mailmerge 1 December 7th 06 10:42 PM
how do i format conditional text in a word mail merge surreyjed Mailmerge 1 January 28th 06 12:56 PM
How do I get a Word mail merge to parce query into an sql string? A. Rhea Mailmerge 0 November 2nd 05 05:21 PM
Query String in Mail Merge XP karen lyons via OfficeKB.com Mailmerge 0 January 13th 05 10:50 PM


All times are GMT +1. The time now is 03:05 PM.

Copyright ©2000 - 2024, Jelsoft Enterprises Ltd.
Copyright ©2004-2024 Microsoft Office Word Forum - WordBanter.
The comments are property of their posters.
 

About Us

"It's about Microsoft Word"