Suppressing Spaces When Merge Field is Blank
-
- PlatinumLounger
- Posts: 3811
- Joined: 24 Oct 2010, 23:39
- Location: Canton, Ohio USA
Suppressing Spaces When Merge Field is Blank
I have searched all over my records and cannot find how I used to do mail merges and suppress or eliminate spaces between fields when there was no data in certain fields. I remember it had to be exact and I created a document to copy exactly what I needed to put in the merge if I wanted the blank field to suppress a space between it and the following field. I believe the attached merge has such a code in the II_Jr field but I don’t know how to access it to view whatever code, I believe, is there. Can anyone tell me how I can view the code in the II_Jr field of the attached merge? Thanks.
You do not have the required permissions to view the files attached to this post.
Regards,
hlewton
hlewton
-
- Administrator
- Posts: 78488
- Joined: 16 Jan 2010, 00:14
- Status: Microsoft MVP
- Location: Wageningen, The Netherlands
Re: Suppressing Spaces When Merge Field is Blank
If you press Alt+F9, you will see the field codes. The field code for the II)Jr field is
{ MERGEFIELD II_Jr \f " " }
The switch \f " " means "insert a space after the II_Jr field if the next field is not empty".
See Field codes: MergeField field
{ MERGEFIELD II_Jr \f " " }
The switch \f " " means "insert a space after the II_Jr field if the next field is not empty".
See Field codes: MergeField field
You do not have the required permissions to view the files attached to this post.
Best wishes,
Hans
Hans
-
- PlatinumLounger
- Posts: 3811
- Joined: 24 Oct 2010, 23:39
- Location: Canton, Ohio USA
Re: Suppressing Spaces When Merge Field is Blank
Thank you. I knew it was something like that but could not remember. I also used to have a template or shell document that I could use and insert the exact field I needed to use because, as I recall, the code had to be entered in a specific manner or that code would show up in place of the field. If I typed it, it would not work, but if I copied it and just changed the merge field, it worked fine. I wish I could find where I have that because I know I would not have deleted it. Maybe I can copy that code, once I see it again, and recreate the template again.HansV wrote: ↑25 Feb 2023, 20:10If you press Alt+F9, you will see the field codes. The field code for the II)Jr field is
{ MERGEFIELD II_Jr \f " " }
The switch \f " " means "insert a space after the II_Jr field if the next field is not empty".
See Field codes: MergeField field
S2293.png
Regards,
hlewton
hlewton
-
- Administrator
- Posts: 78488
- Joined: 16 Jan 2010, 00:14
- Status: Microsoft MVP
- Location: Wageningen, The Netherlands
Re: Suppressing Spaces When Merge Field is Blank
You should not type the field brackets { }.
If you want to insert a field manually, press Ctrl+F9 to create the field brackets.
Then type the field code between the brackets.
Finally, press F9 to hide the field code and to update the result.
To insert a field from the ribbon (other than a merge field), activate the Insert tab of the ribbon.
Click Quick Parts > Field... in the Text group.
If you want to insert a field manually, press Ctrl+F9 to create the field brackets.
Then type the field code between the brackets.
Finally, press F9 to hide the field code and to update the result.
To insert a field from the ribbon (other than a merge field), activate the Insert tab of the ribbon.
Click Quick Parts > Field... in the Text group.
You do not have the required permissions to view the files attached to this post.
Best wishes,
Hans
Hans
-
- PlatinumLounger
- Posts: 3811
- Joined: 24 Oct 2010, 23:39
- Location: Canton, Ohio USA
Re: Suppressing Spaces When Merge Field is Blank
First let me ask, is it Ctrl+F9 or Alt+F9 to do it manually? Then if I use whatever it is to open the brackets, once open can I insert the field by selecting Insert Field and selecting it or do I have to type the Field name, after I have typed the code, manually?HansV wrote: ↑25 Feb 2023, 21:32You should not type the field brackets { }.
If you want to insert a field manually, press Ctrl+F9 to create the field brackets.
Then type the field code between the brackets.
Finally, press F9 to hide the field code and to update the result.
To insert a field from the ribbon (other than a merge field), activate the Insert tab of the ribbon.
Click Quick Parts > Field... in the Text group.
S2295.png
Regards,
hlewton
hlewton
-
- Administrator
- Posts: 78488
- Joined: 16 Jan 2010, 00:14
- Status: Microsoft MVP
- Location: Wageningen, The Netherlands
Re: Suppressing Spaces When Merge Field is Blank
Ctrl+F9 creates an empty new field by inserting field brackets { }. Doing so displays the field code for that field.
F9 updates the currently selected field and, if the field code is displayed, hides it.
Shift+F9 toggles the display of the field code on and off for the currently selected field.
Alt+F9 toggles the display of field codes on and off for the whole document.
Ctrl+Shift+F9 replaces the currently selected field with its result (removing the field code).
Also see Keyboard shortcuts in Word
F9 updates the currently selected field and, if the field code is displayed, hides it.
Shift+F9 toggles the display of the field code on and off for the currently selected field.
Alt+F9 toggles the display of field codes on and off for the whole document.
Ctrl+Shift+F9 replaces the currently selected field with its result (removing the field code).
Also see Keyboard shortcuts in Word
Best wishes,
Hans
Hans
-
- PlatinumLounger
- Posts: 3811
- Joined: 24 Oct 2010, 23:39
- Location: Canton, Ohio USA
Re: Suppressing Spaces When Merge Field is Blank
Thank you for that information. I believe by finagling things around a bit, I ended up with the results I needed with the other merges I was working with. I appreciate your help because without knowing how to look at those field codes using Alt+F9, I wouldn't have known I was using the correct merges I created long ago to update my current ones.HansV wrote: ↑25 Feb 2023, 22:03Ctrl+F9 creates an empty new field by inserting field brackets { }. Doing so displays the field code for that field.
F9 updates the currently selected field and, if the field code is displayed, hides it.
Shift+F9 toggles the display of the field code on and off for the currently selected field.
Alt+F9 toggles the display of field codes on and off for the whole document.
Ctrl+Shift+F9 replaces the currently selected field with its result (removing the field code).
Also see Keyboard shortcuts in Word
Regards,
hlewton
hlewton
-
- 5StarLounger
- Posts: 617
- Joined: 10 Jan 2016, 15:56
- Location: Madison, Wisconsin
Re: Suppressing Spaces When Merge Field is Blank
Here are two references that may help:
- Dealing with Fields in Microsoft Word (my article)https://answers.microsoft.com/en-us/mso ... 786c16a501
- Mailmerge Tips and Tricks (Paul Edstein) http://www.msofficeforums.com/mail-merg ... ricks.html
Attorney Charles Kenyon
Templates in Microsoft Word
Modifying the QAT
The Importance of Styles in Microsoft Word
Templates in Microsoft Word
Modifying the QAT
The Importance of Styles in Microsoft Word
-
- PlatinumLounger
- Posts: 3811
- Joined: 24 Oct 2010, 23:39
- Location: Canton, Ohio USA
Re: Suppressing Spaces When Merge Field is Blank
Thank you. I will check them out.Charles Kenyon wrote: ↑26 Feb 2023, 02:50Here are two references that may help:
- Dealing with Fields in Microsoft Word (my article)https://answers.microsoft.com/en-us/mso ... 786c16a501
(Paul knows much more about mailmerge than I do.)
- Mailmerge Tips and Tricks (Paul Edstein) http://www.msofficeforums.com/mail-merg ... ricks.html
Regards,
hlewton
hlewton
-
- PlatinumLounger
- Posts: 3811
- Joined: 24 Oct 2010, 23:39
- Location: Canton, Ohio USA
Re: Suppressing Spaces When Merge Field is Blank
This is a quote from the second link, "By default, Word 2002 & later use OLE DB to get records from the data source." I remember something from years ago about having to install something like is named here. I can't remember when that went away but I have not had to install anything like that in recent years.
I still can't find my instructions I typed years ago but I must have been concerned about my memory for using code inside my mail merges. I found a couple shell merges that had all the code I have ever needed and those merges are what I used to finagle new merges, as I mentioned above. As I'm sure you guys know, from those shell documents I can create any size font and link to any database I want to. Then all I had to do was save them under a new name and save the connection to whatever database I linked them to. Luckily, no matter if I used Access or Excel files as the database, I kept all the fields consistent. Being refreshed about the use of Alt+F9 allowed me to see the shell merges I had created years ago and make use of them for my new mail merges.
I still can't find my instructions I typed years ago but I must have been concerned about my memory for using code inside my mail merges. I found a couple shell merges that had all the code I have ever needed and those merges are what I used to finagle new merges, as I mentioned above. As I'm sure you guys know, from those shell documents I can create any size font and link to any database I want to. Then all I had to do was save them under a new name and save the connection to whatever database I linked them to. Luckily, no matter if I used Access or Excel files as the database, I kept all the fields consistent. Being refreshed about the use of Alt+F9 allowed me to see the shell merges I had created years ago and make use of them for my new mail merges.
Regards,
hlewton
hlewton
-
- 5StarLounger
- Posts: 617
- Joined: 10 Jan 2016, 15:56
- Location: Madison, Wisconsin
Re: Suppressing Spaces When Merge Field is Blank
I'm glad you are getting it back together.
In Word jargon the shell documents are called primary merge documents.
In Word jargon the shell documents are called primary merge documents.
Attorney Charles Kenyon
Templates in Microsoft Word
Modifying the QAT
The Importance of Styles in Microsoft Word
Templates in Microsoft Word
Modifying the QAT
The Importance of Styles in Microsoft Word
-
- PlatinumLounger
- Posts: 3811
- Joined: 24 Oct 2010, 23:39
- Location: Canton, Ohio USA
Re: Suppressing Spaces When Merge Field is Blank
Maybe I will rename them and hope to remember in the future.Charles Kenyon wrote: ↑26 Feb 2023, 19:56I'm glad you are getting it back together.
In Word jargon the shell documents are called primary merge documents.
Regards,
hlewton
hlewton