Home |
Search |
Today's Posts |
#1
|
|||
|
|||
Re-create the catalog merge by removing all breaks Help
I'm trying to re-create the catalog merge by removing all the section breaks
from within the form letter merge by using a macro but it doesn't seem it work. I have the following fields surrounded by a table. «rownum» «DOCUMENTTITLE» «CTRY» «CLAIMS» FYI: I cannot use the catalog merge because it's not available through the database we use. The SQL database is linked to word. So when the user selects the form. The form displays and prints. We only have access to the simple form letter merges. Basically I'm trying to change the behavior of the form letter. |
#2
|
|||
|
|||
You don't say what the exact problem is but my guess is that Word simply
does not remove any section breaks (except possibly the last) if you replace "^b" by nothing. Unfortunately, that's because there's a weird "feature" in Word where it won't replace stuff between table rows if it would lead to the rows being joined together again. I think you will need a macro such as the following: Sub RemoveSectionBreaks() With ActiveDocument.Content .Find.ClearFormatting Do While .Find.Execute(FindText:="^b", Forward:=True, _ Format:=False) = True .Delete Unit:=wdCharacter, Count:=1 Loop End With End Sub If you aren't familiar with how to use macros, see http://word.mvps.org/FAQs/MacrosVBA/CreateAMacro.htm However, from what you say about not being able to choose catalog/directory merges, it may be that you are also not allowed to create/use macros. If so, you may be able to work around this if you are allowed to change your mail merge main document, as long as none of the merge fields contain multiline data. To try that, instead of putting the merge fields in a table, just separate them using tabs. Then, after the merge, you should be able to replace ^b by nothing (or ^p^b or ^b^p by nothing if there are blank paragraphs to remove as well). Then select all the data and use the Table|"Convert text to table" option to create the table you want (I think!) Peter Jamieson "Jeanne Moos" wrote in message ... I'm trying to re-create the catalog merge by removing all the section breaks from within the form letter merge by using a macro but it doesn't seem it work. I have the following fields surrounded by a table. «rownum» «DOCUMENTTITLE» «CTRY» «CLAIMS» FYI: I cannot use the catalog merge because it's not available through the database we use. The SQL database is linked to word. So when the user selects the form. The form displays and prints. We only have access to the simple form letter merges. Basically I'm trying to change the behavior of the form letter. |
#3
|
|||
|
|||
Thank you. The section break vbscript works! Your second alternative won't
work because I have a multiline data. I have related question: My word document is a template (.dot) file. The script only work if I go into the Macro area and select run. Is there any the script can be changed so that when the file opens it performs the section break removal. Thanks "Peter Jamieson" wrote: You don't say what the exact problem is but my guess is that Word simply does not remove any section breaks (except possibly the last) if you replace "^b" by nothing. Unfortunately, that's because there's a weird "feature" in Word where it won't replace stuff between table rows if it would lead to the rows being joined together again. I think you will need a macro such as the following: Sub RemoveSectionBreaks() With ActiveDocument.Content .Find.ClearFormatting Do While .Find.Execute(FindText:="^b", Forward:=True, _ Format:=False) = True .Delete Unit:=wdCharacter, Count:=1 Loop End With End Sub If you aren't familiar with how to use macros, see http://word.mvps.org/FAQs/MacrosVBA/CreateAMacro.htm However, from what you say about not being able to choose catalog/directory merges, it may be that you are also not allowed to create/use macros. If so, you may be able to work around this if you are allowed to change your mail merge main document, as long as none of the merge fields contain multiline data. To try that, instead of putting the merge fields in a table, just separate them using tabs. Then, after the merge, you should be able to replace ^b by nothing (or ^p^b or ^b^p by nothing if there are blank paragraphs to remove as well). Then select all the data and use the Table|"Convert text to table" option to create the table you want (I think!) Peter Jamieson "Jeanne Moos" wrote in message ... I'm trying to re-create the catalog merge by removing all the section breaks from within the form letter merge by using a macro but it doesn't seem it work. I have the following fields surrounded by a table. «rownum» «DOCUMENTTITLE» «CTRY» «CLAIMS» FYI: I cannot use the catalog merge because it's not available through the database we use. The SQL database is linked to word. So when the user selects the form. The form displays and prints. We only have access to the simple form letter merges. Basically I'm trying to change the behavior of the form letter. |
#4
|
|||
|
|||
Taking your description at face value, what you can do is make a copy of the
macro in your template in a Module (i.e. don't put it under ThisDocument: - use Insert Module to create a new module - (for this kind of macro I usually rename the module to "AutoMacros" but it isn't essential) - copy/paste the code of the Sub into the new module - change the name of the Sub to AutoOpen, so you have Sub AutoOpen() at the top. Then save the template. What that should do is make any document based on that template exxeute the code when the document opens. However, a. you need to be sure that it is always OK to perform this action for any document attached to this template b. you should test the macro to ensure that it works (preferably not popping up any dialog boxes) when there is nothing to replace c. you need to be sure that the document resulting from your merge is attached to the template you think it's attached to :-) If that is all OK, fine. Otherwise, let us know what goes wrong... Peter Jamieson "Jeanne Moos" wrote in message ... Thank you. The section break vbscript works! Your second alternative won't work because I have a multiline data. I have related question: My word document is a template (.dot) file. The script only work if I go into the Macro area and select run. Is there any the script can be changed so that when the file opens it performs the section break removal. Thanks "Peter Jamieson" wrote: You don't say what the exact problem is but my guess is that Word simply does not remove any section breaks (except possibly the last) if you replace "^b" by nothing. Unfortunately, that's because there's a weird "feature" in Word where it won't replace stuff between table rows if it would lead to the rows being joined together again. I think you will need a macro such as the following: Sub RemoveSectionBreaks() With ActiveDocument.Content .Find.ClearFormatting Do While .Find.Execute(FindText:="^b", Forward:=True, _ Format:=False) = True .Delete Unit:=wdCharacter, Count:=1 Loop End With End Sub If you aren't familiar with how to use macros, see http://word.mvps.org/FAQs/MacrosVBA/CreateAMacro.htm However, from what you say about not being able to choose catalog/directory merges, it may be that you are also not allowed to create/use macros. If so, you may be able to work around this if you are allowed to change your merge main document, as long as none of the merge fields contain multiline data. To try that, instead of putting the merge fields in a table, just separate them using tabs. Then, after the merge, you should be able to replace ^b by nothing (or ^p^b or ^b^p by nothing if there are blank paragraphs to remove as well). Then select all the data and use the Table|"Convert text to table" option to create the table you want (I think!) Peter Jamieson "Jeanne Moos" wrote in message ... I'm trying to re-create the catalog merge by removing all the section breaks from within the form letter merge by using a macro but it doesn't seem it work. I have the following fields surrounded by a table. «rownum» «DOCUMENTTITLE» «CTRY» «CLAIMS» FYI: I cannot use the catalog merge because it's not available through the database we use. The SQL database is linked to word. So when the user selects the form. The form displays and prints. We only have access to the simple form letter merges. Basically I'm trying to change the behavior of the form letter. |
#5
|
|||
|
|||
I took your advice and place the following code as a module in my Word
template called RemoveBreaks.dot. Sub AutoOpen() With ActiveDocument.Content .Find.ClearFormatting Do While .Find.Execute(FindText:="^b", Forward:=True, _ Format:=False) = True .Delete Unit:=wdCharacter, Count:=1 Loop End With End Sub When I open the document the script doesn't work. It doesn't remove the section breaks. When I open the template .dot it turns into a doc. file. When I go to the macro section of the doc file the macro isn't there. I guess it still resides in the .dot file. Any suggestions? "Peter Jamieson" wrote: Taking your description at face value, what you can do is make a copy of the macro in your template in a Module (i.e. don't put it under ThisDocument: - use Insert Module to create a new module - (for this kind of macro I usually rename the module to "AutoMacros" but it isn't essential) - copy/paste the code of the Sub into the new module - change the name of the Sub to AutoOpen, so you have Sub AutoOpen() at the top. Then save the template. What that should do is make any document based on that template exxeute the code when the document opens. However, a. you need to be sure that it is always OK to perform this action for any document attached to this template b. you should test the macro to ensure that it works (preferably not popping up any dialog boxes) when there is nothing to replace c. you need to be sure that the document resulting from your merge is attached to the template you think it's attached to :-) If that is all OK, fine. Otherwise, let us know what goes wrong... Peter Jamieson "Jeanne Moos" wrote in message ... Thank you. The section break vbscript works! Your second alternative won't work because I have a multiline data. I have related question: My word document is a template (.dot) file. The script only work if I go into the Macro area and select run. Is there any the script can be changed so that when the file opens it performs the section break removal. Thanks "Peter Jamieson" wrote: You don't say what the exact problem is but my guess is that Word simply does not remove any section breaks (except possibly the last) if you replace "^b" by nothing. Unfortunately, that's because there's a weird "feature" in Word where it won't replace stuff between table rows if it would lead to the rows being joined together again. I think you will need a macro such as the following: Sub RemoveSectionBreaks() With ActiveDocument.Content .Find.ClearFormatting Do While .Find.Execute(FindText:="^b", Forward:=True, _ Format:=False) = True .Delete Unit:=wdCharacter, Count:=1 Loop End With End Sub If you aren't familiar with how to use macros, see http://word.mvps.org/FAQs/MacrosVBA/CreateAMacro.htm However, from what you say about not being able to choose catalog/directory merges, it may be that you are also not allowed to create/use macros. If so, you may be able to work around this if you are allowed to change your merge main document, as long as none of the merge fields contain multiline data. To try that, instead of putting the merge fields in a table, just separate them using tabs. Then, after the merge, you should be able to replace ^b by nothing (or ^p^b or ^b^p by nothing if there are blank paragraphs to remove as well). Then select all the data and use the Table|"Convert text to table" option to create the table you want (I think!) Peter Jamieson "Jeanne Moos" wrote in message ... I'm trying to re-create the catalog merge by removing all the section breaks from within the form letter merge by using a macro but it doesn't seem it work. I have the following fields surrounded by a table. «rownum» «DOCUMENTTITLE» «CTRY» «CLAIMS» FYI: I cannot use the catalog merge because it's not available through the database we use. The SQL database is linked to word. So when the user selects the form. The form displays and prints. We only have access to the simple form letter merges. Basically I'm trying to change the behavior of the form letter. |
#6
|
|||
|
|||
When you are working with .dot files everything works a bit differently. How
it was supposed to work is that you use File|New, then pick the template, and as you say a new .doc is created based on the template. Some of the material in the template (e.g. page layout and any text etc. in it) is copied to the new .doc, but some other things (macros and autotexts) remain in the template. However, as long as the document remains "attached" to the template, the macro should run when you open the document. You can see which template the document is attached to by looking at Tools|Templates and Addins. The reason why I suggested an autoopen is that as far as I could tell, I thought you would be re-opening an existing document that was based on your template. If you are creating a new document a. change the name of the macro to AutoNew() b. I'm not sure it makes sense because when you create your document it will have nothing in it to remove. If you can describe exactly how you want the process to work, it may be that neither an AutoOpen nor an AutoNew will work. Peter Jamieson "Jeanne Moos" wrote in message ... I took your advice and place the following code as a module in my Word template called RemoveBreaks.dot. Sub AutoOpen() With ActiveDocument.Content .Find.ClearFormatting Do While .Find.Execute(FindText:="^b", Forward:=True, _ Format:=False) = True .Delete Unit:=wdCharacter, Count:=1 Loop End With End Sub When I open the document the script doesn't work. It doesn't remove the section breaks. When I open the template .dot it turns into a doc. file. When I go to the macro section of the doc file the macro isn't there. I guess it still resides in the .dot file. Any suggestions? "Peter Jamieson" wrote: Taking your description at face value, what you can do is make a copy of the macro in your template in a Module (i.e. don't put it under ThisDocument: - use Insert Module to create a new module - (for this kind of macro I usually rename the module to "AutoMacros" but it isn't essential) - copy/paste the code of the Sub into the new module - change the name of the Sub to AutoOpen, so you have Sub AutoOpen() at the top. Then save the template. What that should do is make any document based on that template exxeute the code when the document opens. However, a. you need to be sure that it is always OK to perform this action for any document attached to this template b. you should test the macro to ensure that it works (preferably not popping up any dialog boxes) when there is nothing to replace c. you need to be sure that the document resulting from your merge is attached to the template you think it's attached to :-) If that is all OK, fine. Otherwise, let us know what goes wrong... Peter Jamieson "Jeanne Moos" wrote in message ... Thank you. The section break vbscript works! Your second alternative won't work because I have a multiline data. I have related question: My word document is a template (.dot) file. The script only work if I go into the Macro area and select run. Is there any the script can be changed so that when the file opens it performs the section break removal. Thanks "Peter Jamieson" wrote: You don't say what the exact problem is but my guess is that Word simply does not remove any section breaks (except possibly the last) if you replace "^b" by nothing. Unfortunately, that's because there's a weird "feature" in Word where it won't replace stuff between table rows if it would lead to the rows being joined together again. I think you will need a macro such as the following: Sub RemoveSectionBreaks() With ActiveDocument.Content .Find.ClearFormatting Do While .Find.Execute(FindText:="^b", Forward:=True, _ Format:=False) = True .Delete Unit:=wdCharacter, Count:=1 Loop End With End Sub If you aren't familiar with how to use macros, see http://word.mvps.org/FAQs/MacrosVBA/CreateAMacro.htm However, from what you say about not being able to choose catalog/directory merges, it may be that you are also not allowed to create/use macros. If so, you may be able to work around this if you are allowed to change your merge main document, as long as none of the merge fields contain multiline data. To try that, instead of putting the merge fields in a table, just separate them using tabs. Then, after the merge, you should be able to replace ^b by nothing (or ^p^b or ^b^p by nothing if there are blank paragraphs to remove as well). Then select all the data and use the Table|"Convert text to table" option to create the table you want (I think!) Peter Jamieson "Jeanne Moos" wrote in message ... I'm trying to re-create the catalog merge by removing all the section breaks from within the form letter merge by using a macro but it doesn't seem it work. I have the following fields surrounded by a table. «rownum» «DOCUMENTTITLE» «CTRY» «CLAIMS» FYI: I cannot use the catalog merge because it's not available through the database we use. The SQL database is linked to word. So when the user selects the form. The form displays and prints. We only have access to the simple form letter merges. Basically I'm trying to change the behavior of the form letter. |
#7
|
|||
|
|||
Neither of your automated suggestions work with the database/word merge. The
only time the "remove the section breaks" script works is if I create a new macro for the form letter that opens. I thought maybe now that the user will have to run the script themselves. Is there any way a user form can be used to prompt the user to the run the script? "Peter Jamieson" wrote: When you are working with .dot files everything works a bit differently. How it was supposed to work is that you use File|New, then pick the template, and as you say a new .doc is created based on the template. Some of the material in the template (e.g. page layout and any text etc. in it) is copied to the new .doc, but some other things (macros and autotexts) remain in the template. However, as long as the document remains "attached" to the template, the macro should run when you open the document. You can see which template the document is attached to by looking at Tools|Templates and Addins. The reason why I suggested an autoopen is that as far as I could tell, I thought you would be re-opening an existing document that was based on your template. If you are creating a new document a. change the name of the macro to AutoNew() b. I'm not sure it makes sense because when you create your document it will have nothing in it to remove. If you can describe exactly how you want the process to work, it may be that neither an AutoOpen nor an AutoNew will work. Peter Jamieson "Jeanne Moos" wrote in message ... I took your advice and place the following code as a module in my Word template called RemoveBreaks.dot. Sub AutoOpen() With ActiveDocument.Content .Find.ClearFormatting Do While .Find.Execute(FindText:="^b", Forward:=True, _ Format:=False) = True .Delete Unit:=wdCharacter, Count:=1 Loop End With End Sub When I open the document the script doesn't work. It doesn't remove the section breaks. When I open the template .dot it turns into a doc. file. When I go to the macro section of the doc file the macro isn't there. I guess it still resides in the .dot file. Any suggestions? "Peter Jamieson" wrote: Taking your description at face value, what you can do is make a copy of the macro in your template in a Module (i.e. don't put it under ThisDocument: - use Insert Module to create a new module - (for this kind of macro I usually rename the module to "AutoMacros" but it isn't essential) - copy/paste the code of the Sub into the new module - change the name of the Sub to AutoOpen, so you have Sub AutoOpen() at the top. Then save the template. What that should do is make any document based on that template exxeute the code when the document opens. However, a. you need to be sure that it is always OK to perform this action for any document attached to this template b. you should test the macro to ensure that it works (preferably not popping up any dialog boxes) when there is nothing to replace c. you need to be sure that the document resulting from your merge is attached to the template you think it's attached to :-) If that is all OK, fine. Otherwise, let us know what goes wrong... Peter Jamieson "Jeanne Moos" wrote in message ... Thank you. The section break vbscript works! Your second alternative won't work because I have a multiline data. I have related question: My word document is a template (.dot) file. The script only work if I go into the Macro area and select run. Is there any the script can be changed so that when the file opens it performs the section break removal. Thanks "Peter Jamieson" wrote: You don't say what the exact problem is but my guess is that Word simply does not remove any section breaks (except possibly the last) if you replace "^b" by nothing. Unfortunately, that's because there's a weird "feature" in Word where it won't replace stuff between table rows if it would lead to the rows being joined together again. I think you will need a macro such as the following: Sub RemoveSectionBreaks() With ActiveDocument.Content .Find.ClearFormatting Do While .Find.Execute(FindText:="^b", Forward:=True, _ Format:=False) = True .Delete Unit:=wdCharacter, Count:=1 Loop End With End Sub If you aren't familiar with how to use macros, see http://word.mvps.org/FAQs/MacrosVBA/CreateAMacro.htm However, from what you say about not being able to choose catalog/directory merges, it may be that you are also not allowed to create/use macros. If so, you may be able to work around this if you are allowed to change your merge main document, as long as none of the merge fields contain multiline data. To try that, instead of putting the merge fields in a table, just separate them using tabs. Then, after the merge, you should be able to replace ^b by nothing (or ^p^b or ^b^p by nothing if there are blank paragraphs to remove as well). Then select all the data and use the Table|"Convert text to table" option to create the table you want (I think!) Peter Jamieson "Jeanne Moos" wrote in message ... I'm trying to re-create the catalog merge by removing all the section breaks from within the form letter merge by using a macro but it doesn't seem it work. I have the following fields surrounded by a table. «rownum» «DOCUMENTTITLE» «CTRY» «CLAIMS» FYI: I cannot use the catalog merge because it's not available through the database we use. The SQL database is linked to word. So when the user selects the form. The form displays and prints. We only have access to the simple form letter merges. Basically I'm trying to change the behavior of the form letter. |
#8
|
|||
|
|||
I just want to thank Peter Jamieson for his help. The code was perfect. The
reason it didn't work was because I need an additional statement to allow the database to talk to my macro. "Jeanne Moos" wrote: Neither of your automated suggestions work with the database/word merge. The only time the "remove the section breaks" script works is if I create a new macro for the form letter that opens. I thought maybe now that the user will have to run the script themselves. Is there any way a user form can be used to prompt the user to the run the script? "Peter Jamieson" wrote: When you are working with .dot files everything works a bit differently. How it was supposed to work is that you use File|New, then pick the template, and as you say a new .doc is created based on the template. Some of the material in the template (e.g. page layout and any text etc. in it) is copied to the new .doc, but some other things (macros and autotexts) remain in the template. However, as long as the document remains "attached" to the template, the macro should run when you open the document. You can see which template the document is attached to by looking at Tools|Templates and Addins. The reason why I suggested an autoopen is that as far as I could tell, I thought you would be re-opening an existing document that was based on your template. If you are creating a new document a. change the name of the macro to AutoNew() b. I'm not sure it makes sense because when you create your document it will have nothing in it to remove. If you can describe exactly how you want the process to work, it may be that neither an AutoOpen nor an AutoNew will work. Peter Jamieson "Jeanne Moos" wrote in message ... I took your advice and place the following code as a module in my Word template called RemoveBreaks.dot. Sub AutoOpen() With ActiveDocument.Content .Find.ClearFormatting Do While .Find.Execute(FindText:="^b", Forward:=True, _ Format:=False) = True .Delete Unit:=wdCharacter, Count:=1 Loop End With End Sub When I open the document the script doesn't work. It doesn't remove the section breaks. When I open the template .dot it turns into a doc. file. When I go to the macro section of the doc file the macro isn't there. I guess it still resides in the .dot file. Any suggestions? "Peter Jamieson" wrote: Taking your description at face value, what you can do is make a copy of the macro in your template in a Module (i.e. don't put it under ThisDocument: - use Insert Module to create a new module - (for this kind of macro I usually rename the module to "AutoMacros" but it isn't essential) - copy/paste the code of the Sub into the new module - change the name of the Sub to AutoOpen, so you have Sub AutoOpen() at the top. Then save the template. What that should do is make any document based on that template exxeute the code when the document opens. However, a. you need to be sure that it is always OK to perform this action for any document attached to this template b. you should test the macro to ensure that it works (preferably not popping up any dialog boxes) when there is nothing to replace c. you need to be sure that the document resulting from your merge is attached to the template you think it's attached to :-) If that is all OK, fine. Otherwise, let us know what goes wrong... Peter Jamieson "Jeanne Moos" wrote in message ... Thank you. The section break vbscript works! Your second alternative won't work because I have a multiline data. I have related question: My word document is a template (.dot) file. The script only work if I go into the Macro area and select run. Is there any the script can be changed so that when the file opens it performs the section break removal. Thanks "Peter Jamieson" wrote: You don't say what the exact problem is but my guess is that Word simply does not remove any section breaks (except possibly the last) if you replace "^b" by nothing. Unfortunately, that's because there's a weird "feature" in Word where it won't replace stuff between table rows if it would lead to the rows being joined together again. I think you will need a macro such as the following: Sub RemoveSectionBreaks() With ActiveDocument.Content .Find.ClearFormatting Do While .Find.Execute(FindText:="^b", Forward:=True, _ Format:=False) = True .Delete Unit:=wdCharacter, Count:=1 Loop End With End Sub If you aren't familiar with how to use macros, see http://word.mvps.org/FAQs/MacrosVBA/CreateAMacro.htm However, from what you say about not being able to choose catalog/directory merges, it may be that you are also not allowed to create/use macros. If so, you may be able to work around this if you are allowed to change your merge main document, as long as none of the merge fields contain multiline data. To try that, instead of putting the merge fields in a table, just separate them using tabs. Then, after the merge, you should be able to replace ^b by nothing (or ^p^b or ^b^p by nothing if there are blank paragraphs to remove as well). Then select all the data and use the Table|"Convert text to table" option to create the table you want (I think!) Peter Jamieson "Jeanne Moos" wrote in message ... I'm trying to re-create the catalog merge by removing all the section breaks from within the form letter merge by using a macro but it doesn't seem it work. I have the following fields surrounded by a table. «rownum» «DOCUMENTTITLE» «CTRY» «CLAIMS» FYI: I cannot use the catalog merge because it's not available through the database we use. The SQL database is linked to word. So when the user selects the form. The form displays and prints. We only have access to the simple form letter merges. Basically I'm trying to change the behavior of the form letter. |
Reply |
Thread Tools | |
Display Modes | |
|
|
Similar Threads | ||||
Thread | Forum | |||
Mail Merge: How do you merge to file but create separate files | Mailmerge | |||
Can you create a multi-layered merge where certain merge fields a. | Mailmerge | |||
Mail merge to append / create a document? | Mailmerge | |||
How do I create separate files for each document a mail merge cre. | Mailmerge | |||
how do i create a mail merge for email using excel as a data sourc | Mailmerge |