Home |
Search |
Today's Posts |
#1
Posted to microsoft.public.word.newusers
|
|||
|
|||
How to remove automatically some pages?
Hi All,
I have a big MS Word 97 file. I am looking for any method that let me remove automatically some pages which I can mark using, for example, a special character as the first on each page or in any other way. I would be also satisfied if I could automatically skip the pages whilst printing the file. I can use the MS Word 2007 to do it, if necessary. Could anyone help me please? The matter is urgent.:-) Regards Tico |
#2
Posted to microsoft.public.word.newusers
|
|||
|
|||
How to remove automatically some pages?
Hi All,
I have a big MS Word 97 file. To be precise: I'll create this big file using MailMerge so I can add any special character at the beginning of each page or so. Unfortunately I am not able to skip the pages using methods available in MailMerge. I have to do it after creating the file. I am looking for any method that let me remove automatically some pages which I can mark using, for example, a special character as the first on each page or in any other way. I would be also satisfied if I could automatically skip the pages whilst printing the file. I can use the MS Word 2007 to do it, if necessary. Could anyone help me please? The matter is urgent.:-) Regards Tico |
#3
Posted to microsoft.public.word.newusers
|
|||
|
|||
How to remove automatically some pages?
Use a macro containing the following code where you replace the #*# with the
special character that you intend to use. Selection.HomeKey wdStory Selection.Find.ClearFormatting With Selection.Find Do While .Execute(FindText:="#*#", MatchWildcards:=False, Wrap:=wdFindContinue, Forward:=True) = True Selection.Bookmarks("\page").Range.Delete Loop End With -- 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 "Tico" wrote in message ... Hi All, I have a big MS Word 97 file. I am looking for any method that let me remove automatically some pages which I can mark using, for example, a special character as the first on each page or in any other way. I would be also satisfied if I could automatically skip the pages whilst printing the file. I can use the MS Word 2007 to do it, if necessary. Could anyone help me please? The matter is urgent.:-) Regards Tico |
#4
Posted to microsoft.public.word.newusers
|
|||
|
|||
How to remove automatically some pages?
Thank you very much for your prompt reply.
Unfortunately I don't know enough about macros to be able to use the macro. When I tried to use it I got the following lines in red: Do While .Execute(FindText:="#*#", MatchWildcards:=False, Wrap:=wdFindContinue, Forward:=True) = True Selection.Bookmarks("\page").Range.Delete regardless what I replaced the "#*#" with. My special character is \. I don't even know what I should writei n the macro: "#\#", "\" or simply \ I haven't found FindText in the "VBA for Dummies" for Office 97 that I have so I think I should save my file as Word 2007 first and then use the macro. I have Office 2007 (home edition) but I am not familiar with it yet, at least not to use macros. I am afraid I'll have to remove the pages manually. :-( Regards Tico Użytkownik "Doug Robbins - Word MVP" napisał w wiadomości ... Use a macro containing the following code where you replace the #*# with the special character that you intend to use. Selection.HomeKey wdStory Selection.Find.ClearFormatting With Selection.Find Do While .Execute(FindText:="#*#", MatchWildcards:=False, Wrap:=wdFindContinue, Forward:=True) = True Selection.Bookmarks("\page").Range.Delete Loop End With -- 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 "Tico" wrote in message ... Hi All, I have a big MS Word 97 file. I am looking for any method that let me remove automatically some pages which I can mark using, for example, a special character as the first on each page or in any other way. I would be also satisfied if I could automatically skip the pages whilst printing the file. I can use the MS Word 2007 to do it, if necessary. Could anyone help me please? The matter is urgent.:-) Regards Tico |
#5
Posted to microsoft.public.word.newusers
|
|||
|
|||
How to remove automatically some pages?
The lines indicated in red have wrapped prematurely use the following which
should not wrap Sub DeleteMarkedPages() Selection.HomeKey wdStory Selection.Find.ClearFormatting With Selection.Find Do While .Execute(findText:="\", _ MatchWildcards:=False, _ Wrap:=wdFindContinue, _ Forward:=True) = True Selection.Bookmarks("\page").Range.Delete Loop End With http://www.gmayor.com/installing_macro.htm The macro will remove any page with the \ character in Word 2007 and should work in Word 97 also, though I don't have it available to check. Word 2007 will open a Word document from Word 97 without the need to 'convert' it. -- Graham Mayor - Word MVP My web site www.gmayor.com Word MVP web site http://word.mvps.org Tico wrote: Thank you very much for your prompt reply. Unfortunately I don't know enough about macros to be able to use the macro. When I tried to use it I got the following lines in red: Do While .Execute(FindText:="#*#", MatchWildcards:=False, Wrap:=wdFindContinue, Forward:=True) = True Selection.Bookmarks("\page").Range.Delete regardless what I replaced the "#*#" with. My special character is \. I don't even know what I should writei n the macro: "#\#", "\" or simply \ I haven't found FindText in the "VBA for Dummies" for Office 97 that I have so I think I should save my file as Word 2007 first and then use the macro. I have Office 2007 (home edition) but I am not familiar with it yet, at least not to use macros. I am afraid I'll have to remove the pages manually. :-( Regards Tico Użytkownik "Doug Robbins - Word MVP" napisał w wiadomości ... Use a macro containing the following code where you replace the #*# with the special character that you intend to use. Selection.HomeKey wdStory Selection.Find.ClearFormatting With Selection.Find Do While .Execute(FindText:="#*#", MatchWildcards:=False, Wrap:=wdFindContinue, Forward:=True) = True Selection.Bookmarks("\page").Range.Delete Loop End With -- 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 "Tico" wrote in message ... Hi All, I have a big MS Word 97 file. I am looking for any method that let me remove automatically some pages which I can mark using, for example, a special character as the first on each page or in any other way. I would be also satisfied if I could automatically skip the pages whilst printing the file. I can use the MS Word 2007 to do it, if necessary. Could anyone help me please? The matter is urgent.:-) Regards Tico |
#6
Posted to microsoft.public.word.newusers
|
|||
|
|||
How to remove automatically some pages?
Thank you very, very much.
I created a sample file and it works! Now I have to put the macro into my big file which is a result of MailMerge and make a lot of tests. By the way, I know almost nothing about VBA for Word. I looked at your page and I found a lot of interesting things there. However what I need most at the moment is any tutorial how to create simple macros in Word from the very beginning. Not just examples, which are important too, but first of all the most basic rules. I read that one of ways is to record macros using Word and then to analyse it in VBA Editor. I think that this can be useful later, when you know a lot, but not at the beginning. I am looking for any lessons, step by step showing what is neccessary in a macro and what it means. Then more and more functions to write working macros. Having such background I'll be able to learn using other methods. I tried to find anything like this in the Internet to download or use on line, but without any success. I found a lot for Excel but I read that the rules are not the same. Could you please advice me anything suitable for a person who is just starting with writing macros for Word? Thanks again for your help. Regards Tico Użytkownik "Graham Mayor" napisał w wiadomości ... The lines indicated in red have wrapped prematurely use the following which should not wrap Sub DeleteMarkedPages() Selection.HomeKey wdStory Selection.Find.ClearFormatting With Selection.Find Do While .Execute(findText:="\", _ MatchWildcards:=False, _ Wrap:=wdFindContinue, _ Forward:=True) = True Selection.Bookmarks("\page").Range.Delete Loop End With http://www.gmayor.com/installing_macro.htm The macro will remove any page with the \ character in Word 2007 and should work in Word 97 also, though I don't have it available to check. Word 2007 will open a Word document from Word 97 without the need to 'convert' it. -- Graham Mayor - Word MVP My web site www.gmayor.com Word MVP web site http://word.mvps.org Tico wrote: Thank you very much for your prompt reply. Unfortunately I don't know enough about macros to be able to use the macro. When I tried to use it I got the following lines in red: Do While .Execute(FindText:="#*#", MatchWildcards:=False, Wrap:=wdFindContinue, Forward:=True) = True Selection.Bookmarks("\page").Range.Delete regardless what I replaced the "#*#" with. My special character is \. I don't even know what I should writei n the macro: "#\#", "\" or simply \ I haven't found FindText in the "VBA for Dummies" for Office 97 that I have so I think I should save my file as Word 2007 first and then use the macro. I have Office 2007 (home edition) but I am not familiar with it yet, at least not to use macros. I am afraid I'll have to remove the pages manually. :-( Regards Tico Użytkownik "Doug Robbins - Word MVP" napisał w wiadomości ... Use a macro containing the following code where you replace the #*# with the special character that you intend to use. Selection.HomeKey wdStory Selection.Find.ClearFormatting With Selection.Find Do While .Execute(FindText:="#*#", MatchWildcards:=False, Wrap:=wdFindContinue, Forward:=True) = True Selection.Bookmarks("\page").Range.Delete Loop End With -- 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 "Tico" wrote in message ... Hi All, I have a big MS Word 97 file. I am looking for any method that let me remove automatically some pages which I can mark using, for example, a special character as the first on each page or in any other way. I would be also satisfied if I could automatically skip the pages whilst printing the file. I can use the MS Word 2007 to do it, if necessary. Could anyone help me please? The matter is urgent.:-) Regards Tico |
#7
Posted to microsoft.public.word.newusers
|
|||
|
|||
How to remove automatically some pages?
See the article "Getting To Grips With VBA Basics In 15 Minutes" at:
http://www.word.mvps.org/FAQs/Macros...csIn15Mins.htm And many of the other articles at that website. However, be advised that the only way to learn is to do. -- 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 "Tico" wrote in message ... Thank you very, very much. I created a sample file and it works! Now I have to put the macro into my big file which is a result of MailMerge and make a lot of tests. By the way, I know almost nothing about VBA for Word. I looked at your page and I found a lot of interesting things there. However what I need most at the moment is any tutorial how to create simple macros in Word from the very beginning. Not just examples, which are important too, but first of all the most basic rules. I read that one of ways is to record macros using Word and then to analyse it in VBA Editor. I think that this can be useful later, when you know a lot, but not at the beginning. I am looking for any lessons, step by step showing what is neccessary in a macro and what it means. Then more and more functions to write working macros. Having such background I'll be able to learn using other methods. I tried to find anything like this in the Internet to download or use on line, but without any success. I found a lot for Excel but I read that the rules are not the same. Could you please advice me anything suitable for a person who is just starting with writing macros for Word? Thanks again for your help. Regards Tico Użytkownik "Graham Mayor" napisał w wiadomości ... The lines indicated in red have wrapped prematurely use the following which should not wrap Sub DeleteMarkedPages() Selection.HomeKey wdStory Selection.Find.ClearFormatting With Selection.Find Do While .Execute(findText:="\", _ MatchWildcards:=False, _ Wrap:=wdFindContinue, _ Forward:=True) = True Selection.Bookmarks("\page").Range.Delete Loop End With http://www.gmayor.com/installing_macro.htm The macro will remove any page with the \ character in Word 2007 and should work in Word 97 also, though I don't have it available to check. Word 2007 will open a Word document from Word 97 without the need to 'convert' it. -- Graham Mayor - Word MVP My web site www.gmayor.com Word MVP web site http://word.mvps.org Tico wrote: Thank you very much for your prompt reply. Unfortunately I don't know enough about macros to be able to use the macro. When I tried to use it I got the following lines in red: Do While .Execute(FindText:="#*#", MatchWildcards:=False, Wrap:=wdFindContinue, Forward:=True) = True Selection.Bookmarks("\page").Range.Delete regardless what I replaced the "#*#" with. My special character is \. I don't even know what I should writei n the macro: "#\#", "\" or simply \ I haven't found FindText in the "VBA for Dummies" for Office 97 that I have so I think I should save my file as Word 2007 first and then use the macro. I have Office 2007 (home edition) but I am not familiar with it yet, at least not to use macros. I am afraid I'll have to remove the pages manually. :-( Regards Tico Użytkownik "Doug Robbins - Word MVP" napisał w wiadomości ... Use a macro containing the following code where you replace the #*# with the special character that you intend to use. Selection.HomeKey wdStory Selection.Find.ClearFormatting With Selection.Find Do While .Execute(FindText:="#*#", MatchWildcards:=False, Wrap:=wdFindContinue, Forward:=True) = True Selection.Bookmarks("\page").Range.Delete Loop End With -- 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 "Tico" wrote in message ... Hi All, I have a big MS Word 97 file. I am looking for any method that let me remove automatically some pages which I can mark using, for example, a special character as the first on each page or in any other way. I would be also satisfied if I could automatically skip the pages whilst printing the file. I can use the MS Word 2007 to do it, if necessary. Could anyone help me please? The matter is urgent.:-) Regards Tico |
#8
Posted to microsoft.public.word.newusers
|
|||
|
|||
How to remove automatically some pages?
If you are splitting the results of a mail merge, see
http://www.gmayor.com/individual_merge_letters.htm As Doug says, the only way to learn vba is to put it to use to perform simple tasks and then get more adventurous. You can always use the macro recorder to give you some ideas. It is by no means perfect but it does help get you started. You will find lots of coding examples in the vba programming forums and on various web site, including my own. The vba help in Word 2007 is rather better than in earlier versions. -- Graham Mayor - Word MVP My web site www.gmayor.com Word MVP web site http://word.mvps.org Tico wrote: Thank you very, very much. I created a sample file and it works! Now I have to put the macro into my big file which is a result of MailMerge and make a lot of tests. By the way, I know almost nothing about VBA for Word. I looked at your page and I found a lot of interesting things there. However what I need most at the moment is any tutorial how to create simple macros in Word from the very beginning. Not just examples, which are important too, but first of all the most basic rules. I read that one of ways is to record macros using Word and then to analyse it in VBA Editor. I think that this can be useful later, when you know a lot, but not at the beginning. I am looking for any lessons, step by step showing what is neccessary in a macro and what it means. Then more and more functions to write working macros. Having such background I'll be able to learn using other methods. I tried to find anything like this in the Internet to download or use on line, but without any success. I found a lot for Excel but I read that the rules are not the same. Could you please advice me anything suitable for a person who is just starting with writing macros for Word? Thanks again for your help. Regards Tico Użytkownik "Graham Mayor" napisał w wiadomości ... The lines indicated in red have wrapped prematurely use the following which should not wrap Sub DeleteMarkedPages() Selection.HomeKey wdStory Selection.Find.ClearFormatting With Selection.Find Do While .Execute(findText:="\", _ MatchWildcards:=False, _ Wrap:=wdFindContinue, _ Forward:=True) = True Selection.Bookmarks("\page").Range.Delete Loop End With http://www.gmayor.com/installing_macro.htm The macro will remove any page with the \ character in Word 2007 and should work in Word 97 also, though I don't have it available to check. Word 2007 will open a Word document from Word 97 without the need to 'convert' it. -- Graham Mayor - Word MVP My web site www.gmayor.com Word MVP web site http://word.mvps.org Tico wrote: Thank you very much for your prompt reply. Unfortunately I don't know enough about macros to be able to use the macro. When I tried to use it I got the following lines in red: Do While .Execute(FindText:="#*#", MatchWildcards:=False, Wrap:=wdFindContinue, Forward:=True) = True Selection.Bookmarks("\page").Range.Delete regardless what I replaced the "#*#" with. My special character is \. I don't even know what I should writei n the macro: "#\#", "\" or simply \ I haven't found FindText in the "VBA for Dummies" for Office 97 that I have so I think I should save my file as Word 2007 first and then use the macro. I have Office 2007 (home edition) but I am not familiar with it yet, at least not to use macros. I am afraid I'll have to remove the pages manually. :-( Regards Tico Użytkownik "Doug Robbins - Word MVP" napisał w wiadomości ... Use a macro containing the following code where you replace the #*# with the special character that you intend to use. Selection.HomeKey wdStory Selection.Find.ClearFormatting With Selection.Find Do While .Execute(FindText:="#*#", MatchWildcards:=False, Wrap:=wdFindContinue, Forward:=True) = True Selection.Bookmarks("\page").Range.Delete Loop End With -- 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 "Tico" wrote in message ... Hi All, I have a big MS Word 97 file. I am looking for any method that let me remove automatically some pages which I can mark using, for example, a special character as the first on each page or in any other way. I would be also satisfied if I could automatically skip the pages whilst printing the file. I can use the MS Word 2007 to do it, if necessary. Could anyone help me please? The matter is urgent.:-) Regards Tico |
#9
Posted to microsoft.public.word.newusers
|
|||
|
|||
How to remove automatically some pages?
Thank you both very, very much once again.
I used the macro to the big MailMerge output file and it works perfectly. The macro would work faster if it could test just the first character on each page but I don't know how to change it. But it works very well and I am very grateful. As for a tutorial I expected something I had when I learnt other languages which began with "Hello World" or something like this. Then, step by step, it showed how to use more and more complicated language tools. Regards Tico Użytkownik "Graham Mayor" napisał w wiadomości ... If you are splitting the results of a mail merge, see http://www.gmayor.com/individual_merge_letters.htm As Doug says, the only way to learn vba is to put it to use to perform simple tasks and then get more adventurous. You can always use the macro recorder to give you some ideas. It is by no means perfect but it does help get you started. You will find lots of coding examples in the vba programming forums and on various web site, including my own. The vba help in Word 2007 is rather better than in earlier versions. -- Graham Mayor - Word MVP My web site www.gmayor.com Word MVP web site http://word.mvps.org Tico wrote: Thank you very, very much. I created a sample file and it works! Now I have to put the macro into my big file which is a result of MailMerge and make a lot of tests. By the way, I know almost nothing about VBA for Word. I looked at your page and I found a lot of interesting things there. However what I need most at the moment is any tutorial how to create simple macros in Word from the very beginning. Not just examples, which are important too, but first of all the most basic rules. I read that one of ways is to record macros using Word and then to analyse it in VBA Editor. I think that this can be useful later, when you know a lot, but not at the beginning. I am looking for any lessons, step by step showing what is neccessary in a macro and what it means. Then more and more functions to write working macros. Having such background I'll be able to learn using other methods. I tried to find anything like this in the Internet to download or use on line, but without any success. I found a lot for Excel but I read that the rules are not the same. Could you please advice me anything suitable for a person who is just starting with writing macros for Word? Thanks again for your help. Regards Tico Użytkownik "Graham Mayor" napisał w wiadomości ... The lines indicated in red have wrapped prematurely use the following which should not wrap Sub DeleteMarkedPages() Selection.HomeKey wdStory Selection.Find.ClearFormatting With Selection.Find Do While .Execute(findText:="\", _ MatchWildcards:=False, _ Wrap:=wdFindContinue, _ Forward:=True) = True Selection.Bookmarks("\page").Range.Delete Loop End With http://www.gmayor.com/installing_macro.htm The macro will remove any page with the \ character in Word 2007 and should work in Word 97 also, though I don't have it available to check. Word 2007 will open a Word document from Word 97 without the need to 'convert' it. -- Graham Mayor - Word MVP My web site www.gmayor.com Word MVP web site http://word.mvps.org Tico wrote: Thank you very much for your prompt reply. Unfortunately I don't know enough about macros to be able to use the macro. When I tried to use it I got the following lines in red: Do While .Execute(FindText:="#*#", MatchWildcards:=False, Wrap:=wdFindContinue, Forward:=True) = True Selection.Bookmarks("\page").Range.Delete regardless what I replaced the "#*#" with. My special character is \. I don't even know what I should writei n the macro: "#\#", "\" or simply \ I haven't found FindText in the "VBA for Dummies" for Office 97 that I have so I think I should save my file as Word 2007 first and then use the macro. I have Office 2007 (home edition) but I am not familiar with it yet, at least not to use macros. I am afraid I'll have to remove the pages manually. :-( Regards Tico Użytkownik "Doug Robbins - Word MVP" napisał w wiadomości ... Use a macro containing the following code where you replace the #*# with the special character that you intend to use. Selection.HomeKey wdStory Selection.Find.ClearFormatting With Selection.Find Do While .Execute(FindText:="#*#", MatchWildcards:=False, Wrap:=wdFindContinue, Forward:=True) = True Selection.Bookmarks("\page").Range.Delete Loop End With -- 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 "Tico" wrote in message ... Hi All, I have a big MS Word 97 file. I am looking for any method that let me remove automatically some pages which I can mark using, for example, a special character as the first on each page or in any other way. I would be also satisfied if I could automatically skip the pages whilst printing the file. I can use the MS Word 2007 to do it, if necessary. Could anyone help me please? The matter is urgent.:-) Regards Tico |
#10
Posted to microsoft.public.word.newusers
|
|||
|
|||
How to remove automatically some pages?
Page is a vague concept in Word which is not a page layout application and
if you remove pages the document reflows to create a new 'page' structure. -- Graham Mayor - Word MVP My web site www.gmayor.com Word MVP web site http://word.mvps.org Tico wrote: Thank you both very, very much once again. I used the macro to the big MailMerge output file and it works perfectly. The macro would work faster if it could test just the first character on each page but I don't know how to change it. But it works very well and I am very grateful. As for a tutorial I expected something I had when I learnt other languages which began with "Hello World" or something like this. Then, step by step, it showed how to use more and more complicated language tools. Regards Tico Użytkownik "Graham Mayor" napisał w wiadomości ... If you are splitting the results of a mail merge, see http://www.gmayor.com/individual_merge_letters.htm As Doug says, the only way to learn vba is to put it to use to perform simple tasks and then get more adventurous. You can always use the macro recorder to give you some ideas. It is by no means perfect but it does help get you started. You will find lots of coding examples in the vba programming forums and on various web site, including my own. The vba help in Word 2007 is rather better than in earlier versions. -- Graham Mayor - Word MVP My web site www.gmayor.com Word MVP web site http://word.mvps.org Tico wrote: Thank you very, very much. I created a sample file and it works! Now I have to put the macro into my big file which is a result of MailMerge and make a lot of tests. By the way, I know almost nothing about VBA for Word. I looked at your page and I found a lot of interesting things there. However what I need most at the moment is any tutorial how to create simple macros in Word from the very beginning. Not just examples, which are important too, but first of all the most basic rules. I read that one of ways is to record macros using Word and then to analyse it in VBA Editor. I think that this can be useful later, when you know a lot, but not at the beginning. I am looking for any lessons, step by step showing what is neccessary in a macro and what it means. Then more and more functions to write working macros. Having such background I'll be able to learn using other methods. I tried to find anything like this in the Internet to download or use on line, but without any success. I found a lot for Excel but I read that the rules are not the same. Could you please advice me anything suitable for a person who is just starting with writing macros for Word? Thanks again for your help. Regards Tico Użytkownik "Graham Mayor" napisał w wiadomości ... The lines indicated in red have wrapped prematurely use the following which should not wrap Sub DeleteMarkedPages() Selection.HomeKey wdStory Selection.Find.ClearFormatting With Selection.Find Do While .Execute(findText:="\", _ MatchWildcards:=False, _ Wrap:=wdFindContinue, _ Forward:=True) = True Selection.Bookmarks("\page").Range.Delete Loop End With http://www.gmayor.com/installing_macro.htm The macro will remove any page with the \ character in Word 2007 and should work in Word 97 also, though I don't have it available to check. Word 2007 will open a Word document from Word 97 without the need to 'convert' it. -- Graham Mayor - Word MVP My web site www.gmayor.com Word MVP web site http://word.mvps.org Tico wrote: Thank you very much for your prompt reply. Unfortunately I don't know enough about macros to be able to use the macro. When I tried to use it I got the following lines in red: Do While .Execute(FindText:="#*#", MatchWildcards:=False, Wrap:=wdFindContinue, Forward:=True) = True Selection.Bookmarks("\page").Range.Delete regardless what I replaced the "#*#" with. My special character is \. I don't even know what I should writei n the macro: "#\#", "\" or simply \ I haven't found FindText in the "VBA for Dummies" for Office 97 that I have so I think I should save my file as Word 2007 first and then use the macro. I have Office 2007 (home edition) but I am not familiar with it yet, at least not to use macros. I am afraid I'll have to remove the pages manually. :-( Regards Tico Użytkownik "Doug Robbins - Word MVP" napisał w wiadomości ... Use a macro containing the following code where you replace the #*# with the special character that you intend to use. Selection.HomeKey wdStory Selection.Find.ClearFormatting With Selection.Find Do While .Execute(FindText:="#*#", MatchWildcards:=False, Wrap:=wdFindContinue, Forward:=True) = True Selection.Bookmarks("\page").Range.Delete Loop End With -- 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 "Tico" wrote in message ... Hi All, I have a big MS Word 97 file. I am looking for any method that let me remove automatically some pages which I can mark using, for example, a special character as the first on each page or in any other way. I would be also satisfied if I could automatically skip the pages whilst printing the file. I can use the MS Word 2007 to do it, if necessary. Could anyone help me please? The matter is urgent.:-) Regards Tico |
#11
Posted to microsoft.public.word.newusers
|
|||
|
|||
How to remove automatically some pages?
I understand.
I thought that everything was OK but I have one problem: the additional character damages to keeping a part of the first line in the center. I put in Excel file an addition column and the character "\" is put in it, if the page in Word should be deleted or the character " ", if the page in Word should'n be deleted. What is put : "\" or " " depends on other values in Excel file. Everything is OK but the first line on pages with " " is moved much more to the left than the 1 character (" ") should use (the same happens to pages with "\" but it is not important as they are deleted afterwards). The first line on each page consists of the constant text and a number that is put during the MailMerge process, like this ABCDEF GHIJ KLMNOP {MERGEFIELD No} The text should be in the center of the page, and the No on the right side. After I added the character it looks like this: {MERGEFIELD Char}ABCDEF GHIJ KLMNOP {MERGEFIELD No} (Before I put the additional character everything was OK and the constant text was in the center) My MailMerge "source" file consist of 5 pages, not just one. After the process of MailMerging I delete the "extra" pages using the macro from you. Each of the "source" 5 pages has similar first line as I described above. Could you help me once more, please? Regards Tico Użytkownik "Graham Mayor" napisał w wiadomości ... Page is a vague concept in Word which is not a page layout application and if you remove pages the document reflows to create a new 'page' structure. -- Graham Mayor - Word MVP My web site www.gmayor.com Word MVP web site http://word.mvps.org Tico wrote: Thank you both very, very much once again. I used the macro to the big MailMerge output file and it works perfectly. The macro would work faster if it could test just the first character on each page but I don't know how to change it. But it works very well and I am very grateful. As for a tutorial I expected something I had when I learnt other languages which began with "Hello World" or something like this. Then, step by step, it showed how to use more and more complicated language tools. Regards Tico Użytkownik "Graham Mayor" napisał w wiadomości ... If you are splitting the results of a mail merge, see http://www.gmayor.com/individual_merge_letters.htm As Doug says, the only way to learn vba is to put it to use to perform simple tasks and then get more adventurous. You can always use the macro recorder to give you some ideas. It is by no means perfect but it does help get you started. You will find lots of coding examples in the vba programming forums and on various web site, including my own. The vba help in Word 2007 is rather better than in earlier versions. -- Graham Mayor - Word MVP My web site www.gmayor.com Word MVP web site http://word.mvps.org Tico wrote: Thank you very, very much. I created a sample file and it works! Now I have to put the macro into my big file which is a result of MailMerge and make a lot of tests. By the way, I know almost nothing about VBA for Word. I looked at your page and I found a lot of interesting things there. However what I need most at the moment is any tutorial how to create simple macros in Word from the very beginning. Not just examples, which are important too, but first of all the most basic rules. I read that one of ways is to record macros using Word and then to analyse it in VBA Editor. I think that this can be useful later, when you know a lot, but not at the beginning. I am looking for any lessons, step by step showing what is neccessary in a macro and what it means. Then more and more functions to write working macros. Having such background I'll be able to learn using other methods. I tried to find anything like this in the Internet to download or use on line, but without any success. I found a lot for Excel but I read that the rules are not the same. Could you please advice me anything suitable for a person who is just starting with writing macros for Word? Thanks again for your help. Regards Tico Użytkownik "Graham Mayor" napisał w wiadomości ... The lines indicated in red have wrapped prematurely use the following which should not wrap Sub DeleteMarkedPages() Selection.HomeKey wdStory Selection.Find.ClearFormatting With Selection.Find Do While .Execute(findText:="\", _ MatchWildcards:=False, _ Wrap:=wdFindContinue, _ Forward:=True) = True Selection.Bookmarks("\page").Range.Delete Loop End With http://www.gmayor.com/installing_macro.htm The macro will remove any page with the \ character in Word 2007 and should work in Word 97 also, though I don't have it available to check. Word 2007 will open a Word document from Word 97 without the need to 'convert' it. -- Graham Mayor - Word MVP My web site www.gmayor.com Word MVP web site http://word.mvps.org Tico wrote: Thank you very much for your prompt reply. Unfortunately I don't know enough about macros to be able to use the macro. When I tried to use it I got the following lines in red: Do While .Execute(FindText:="#*#", MatchWildcards:=False, Wrap:=wdFindContinue, Forward:=True) = True Selection.Bookmarks("\page").Range.Delete regardless what I replaced the "#*#" with. My special character is \. I don't even know what I should writei n the macro: "#\#", "\" or simply \ I haven't found FindText in the "VBA for Dummies" for Office 97 that I have so I think I should save my file as Word 2007 first and then use the macro. I have Office 2007 (home edition) but I am not familiar with it yet, at least not to use macros. I am afraid I'll have to remove the pages manually. :-( Regards Tico Użytkownik "Doug Robbins - Word MVP" napisał w wiadomości ... Use a macro containing the following code where you replace the #*# with the special character that you intend to use. Selection.HomeKey wdStory Selection.Find.ClearFormatting With Selection.Find Do While .Execute(FindText:="#*#", MatchWildcards:=False, Wrap:=wdFindContinue, Forward:=True) = True Selection.Bookmarks("\page").Range.Delete Loop End With -- 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 "Tico" wrote in message ... Hi All, I have a big MS Word 97 file. I am looking for any method that let me remove automatically some pages which I can mark using, for example, a special character as the first on each page or in any other way. I would be also satisfied if I could automatically skip the pages whilst printing the file. I can use the MS Word 2007 to do it, if necessary. Could anyone help me please? The matter is urgent.:-) Regards Tico |
#12
Posted to microsoft.public.word.newusers
|
|||
|
|||
How to remove automatically some pages?
The same happens when I put in the Excel file "" instead of " "
when I want a page not to be deleted. I think it is somehow connected with the sign of new page because sometimes it is OK but always after another sign of new page. However i don't know how to force a correct sign in the MaiMerge. Regards Tico Użytkownik "Tico" napisał w wiadomości ... I understand. I thought that everything was OK but I have one problem: the additional character damages to keeping a part of the first line in the center. I put in Excel file an addition column and the character "\" is put in it, if the page in Word should be deleted or the character " ", if the page in Word should'n be deleted. What is put : "\" or " " depends on other values in Excel file. Everything is OK but the first line on pages with " " is moved much more to the left than the 1 character (" ") should use (the same happens to pages with "\" but it is not important as they are deleted afterwards). The first line on each page consists of the constant text and a number that is put during the MailMerge process, like this ABCDEF GHIJ KLMNOP {MERGEFIELD No} The text should be in the center of the page, and the No on the right side. After I added the character it looks like this: {MERGEFIELD Char}ABCDEF GHIJ KLMNOP {MERGEFIELD No} (Before I put the additional character everything was OK and the constant text was in the center) My MailMerge "source" file consist of 5 pages, not just one. After the process of MailMerging I delete the "extra" pages using the macro from you. Each of the "source" 5 pages has similar first line as I described above. Could you help me once more, please? Regards Tico Użytkownik "Graham Mayor" napisał w wiadomości ... Page is a vague concept in Word which is not a page layout application and if you remove pages the document reflows to create a new 'page' structure. -- Graham Mayor - Word MVP My web site www.gmayor.com Word MVP web site http://word.mvps.org Tico wrote: Thank you both very, very much once again. I used the macro to the big MailMerge output file and it works perfectly. The macro would work faster if it could test just the first character on each page but I don't know how to change it. But it works very well and I am very grateful. As for a tutorial I expected something I had when I learnt other languages which began with "Hello World" or something like this. Then, step by step, it showed how to use more and more complicated language tools. Regards Tico Użytkownik "Graham Mayor" napisał w wiadomości ... If you are splitting the results of a mail merge, see http://www.gmayor.com/individual_merge_letters.htm As Doug says, the only way to learn vba is to put it to use to perform simple tasks and then get more adventurous. You can always use the macro recorder to give you some ideas. It is by no means perfect but it does help get you started. You will find lots of coding examples in the vba programming forums and on various web site, including my own. The vba help in Word 2007 is rather better than in earlier versions. -- Graham Mayor - Word MVP My web site www.gmayor.com Word MVP web site http://word.mvps.org Tico wrote: Thank you very, very much. I created a sample file and it works! Now I have to put the macro into my big file which is a result of MailMerge and make a lot of tests. By the way, I know almost nothing about VBA for Word. I looked at your page and I found a lot of interesting things there. However what I need most at the moment is any tutorial how to create simple macros in Word from the very beginning. Not just examples, which are important too, but first of all the most basic rules. I read that one of ways is to record macros using Word and then to analyse it in VBA Editor. I think that this can be useful later, when you know a lot, but not at the beginning. I am looking for any lessons, step by step showing what is neccessary in a macro and what it means. Then more and more functions to write working macros. Having such background I'll be able to learn using other methods. I tried to find anything like this in the Internet to download or use on line, but without any success. I found a lot for Excel but I read that the rules are not the same. Could you please advice me anything suitable for a person who is just starting with writing macros for Word? Thanks again for your help. Regards Tico Użytkownik "Graham Mayor" napisał w wiadomości ... The lines indicated in red have wrapped prematurely use the following which should not wrap Sub DeleteMarkedPages() Selection.HomeKey wdStory Selection.Find.ClearFormatting With Selection.Find Do While .Execute(findText:="\", _ MatchWildcards:=False, _ Wrap:=wdFindContinue, _ Forward:=True) = True Selection.Bookmarks("\page").Range.Delete Loop End With http://www.gmayor.com/installing_macro.htm The macro will remove any page with the \ character in Word 2007 and should work in Word 97 also, though I don't have it available to check. Word 2007 will open a Word document from Word 97 without the need to 'convert' it. -- Graham Mayor - Word MVP My web site www.gmayor.com Word MVP web site http://word.mvps.org Tico wrote: Thank you very much for your prompt reply. Unfortunately I don't know enough about macros to be able to use the macro. When I tried to use it I got the following lines in red: Do While .Execute(FindText:="#*#", MatchWildcards:=False, Wrap:=wdFindContinue, Forward:=True) = True Selection.Bookmarks("\page").Range.Delete regardless what I replaced the "#*#" with. My special character is \. I don't even know what I should writei n the macro: "#\#", "\" or simply \ I haven't found FindText in the "VBA for Dummies" for Office 97 that I have so I think I should save my file as Word 2007 first and then use the macro. I have Office 2007 (home edition) but I am not familiar with it yet, at least not to use macros. I am afraid I'll have to remove the pages manually. :-( Regards Tico Użytkownik "Doug Robbins - Word MVP" napisał w wiadomości ... Use a macro containing the following code where you replace the #*# with the special character that you intend to use. Selection.HomeKey wdStory Selection.Find.ClearFormatting With Selection.Find Do While .Execute(FindText:="#*#", MatchWildcards:=False, Wrap:=wdFindContinue, Forward:=True) = True Selection.Bookmarks("\page").Range.Delete Loop End With -- 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 "Tico" wrote in message ... Hi All, I have a big MS Word 97 file. I am looking for any method that let me remove automatically some pages which I can mark using, for example, a special character as the first on each page or in any other way. I would be also satisfied if I could automatically skip the pages whilst printing the file. I can use the MS Word 2007 to do it, if necessary. Could anyone help me please? The matter is urgent.:-) Regards Tico |
#13
Posted to microsoft.public.word.newusers
|
|||
|
|||
How to remove automatically some pages?
I am totally bemused now. If you don't want the page(s) with this particular
merge record, why are you merging the record in the first place? Wouldn't e.g. {SKIPIF {Mergefield Char} = "\"} work? -- Graham Mayor - Word MVP My web site www.gmayor.com Word MVP web site http://word.mvps.org Tico wrote: The same happens when I put in the Excel file "" instead of " " when I want a page not to be deleted. I think it is somehow connected with the sign of new page because sometimes it is OK but always after another sign of new page. However i don't know how to force a correct sign in the MaiMerge. Regards Tico Użytkownik "Tico" napisał w wiadomości ... I understand. I thought that everything was OK but I have one problem: the additional character damages to keeping a part of the first line in the center. I put in Excel file an addition column and the character "\" is put in it, if the page in Word should be deleted or the character " ", if the page in Word should'n be deleted. What is put : "\" or " " depends on other values in Excel file. Everything is OK but the first line on pages with " " is moved much more to the left than the 1 character (" ") should use (the same happens to pages with "\" but it is not important as they are deleted afterwards). The first line on each page consists of the constant text and a number that is put during the MailMerge process, like this ABCDEF GHIJ KLMNOP {MERGEFIELD No} The text should be in the center of the page, and the No on the right side. After I added the character it looks like this: {MERGEFIELD Char}ABCDEF GHIJ KLMNOP {MERGEFIELD No} (Before I put the additional character everything was OK and the constant text was in the center) My MailMerge "source" file consist of 5 pages, not just one. After the process of MailMerging I delete the "extra" pages using the macro from you. Each of the "source" 5 pages has similar first line as I described above. Could you help me once more, please? Regards Tico Użytkownik "Graham Mayor" napisał w wiadomości ... Page is a vague concept in Word which is not a page layout application and if you remove pages the document reflows to create a new 'page' structure. -- Graham Mayor - Word MVP My web site www.gmayor.com Word MVP web site http://word.mvps.org Tico wrote: Thank you both very, very much once again. I used the macro to the big MailMerge output file and it works perfectly. The macro would work faster if it could test just the first character on each page but I don't know how to change it. But it works very well and I am very grateful. As for a tutorial I expected something I had when I learnt other languages which began with "Hello World" or something like this. Then, step by step, it showed how to use more and more complicated language tools. Regards Tico Użytkownik "Graham Mayor" napisał w wiadomości ... If you are splitting the results of a mail merge, see http://www.gmayor.com/individual_merge_letters.htm As Doug says, the only way to learn vba is to put it to use to perform simple tasks and then get more adventurous. You can always use the macro recorder to give you some ideas. It is by no means perfect but it does help get you started. You will find lots of coding examples in the vba programming forums and on various web site, including my own. The vba help in Word 2007 is rather better than in earlier versions. -- Graham Mayor - Word MVP My web site www.gmayor.com Word MVP web site http://word.mvps.org Tico wrote: Thank you very, very much. I created a sample file and it works! Now I have to put the macro into my big file which is a result of MailMerge and make a lot of tests. By the way, I know almost nothing about VBA for Word. I looked at your page and I found a lot of interesting things there. However what I need most at the moment is any tutorial how to create simple macros in Word from the very beginning. Not just examples, which are important too, but first of all the most basic rules. I read that one of ways is to record macros using Word and then to analyse it in VBA Editor. I think that this can be useful later, when you know a lot, but not at the beginning. I am looking for any lessons, step by step showing what is neccessary in a macro and what it means. Then more and more functions to write working macros. Having such background I'll be able to learn using other methods. I tried to find anything like this in the Internet to download or use on line, but without any success. I found a lot for Excel but I read that the rules are not the same. Could you please advice me anything suitable for a person who is just starting with writing macros for Word? Thanks again for your help. Regards Tico Użytkownik "Graham Mayor" napisał w wiadomości ... The lines indicated in red have wrapped prematurely use the following which should not wrap Sub DeleteMarkedPages() Selection.HomeKey wdStory Selection.Find.ClearFormatting With Selection.Find Do While .Execute(findText:="\", _ MatchWildcards:=False, _ Wrap:=wdFindContinue, _ Forward:=True) = True Selection.Bookmarks("\page").Range.Delete Loop End With http://www.gmayor.com/installing_macro.htm The macro will remove any page with the \ character in Word 2007 and should work in Word 97 also, though I don't have it available to check. Word 2007 will open a Word document from Word 97 without the need to 'convert' it. -- Graham Mayor - Word MVP My web site www.gmayor.com Word MVP web site http://word.mvps.org Tico wrote: Thank you very much for your prompt reply. Unfortunately I don't know enough about macros to be able to use the macro. When I tried to use it I got the following lines in red: Do While .Execute(FindText:="#*#", MatchWildcards:=False, Wrap:=wdFindContinue, Forward:=True) = True Selection.Bookmarks("\page").Range.Delete regardless what I replaced the "#*#" with. My special character is \. I don't even know what I should writei n the macro: "#\#", "\" or simply \ I haven't found FindText in the "VBA for Dummies" for Office 97 that I have so I think I should save my file as Word 2007 first and then use the macro. I have Office 2007 (home edition) but I am not familiar with it yet, at least not to use macros. I am afraid I'll have to remove the pages manually. :-( Regards Tico Użytkownik "Doug Robbins - Word MVP" napisał w wiadomości ... Use a macro containing the following code where you replace the #*# with the special character that you intend to use. Selection.HomeKey wdStory Selection.Find.ClearFormatting With Selection.Find Do While .Execute(FindText:="#*#", MatchWildcards:=False, Wrap:=wdFindContinue, Forward:=True) = True Selection.Bookmarks("\page").Range.Delete Loop End With -- 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 "Tico" wrote in message ... Hi All, I have a big MS Word 97 file. I am looking for any method that let me remove automatically some pages which I can mark using, for example, a special character as the first on each page or in any other way. I would be also satisfied if I could automatically skip the pages whilst printing the file. I can use the MS Word 2007 to do it, if necessary. Could anyone help me please? The matter is urgent.:-) Regards Tico |
#14
Posted to microsoft.public.word.newusers
|
|||
|
|||
How to remove automatically some pages?
No because SKIPIF cause to skip a whole record.
But I have to "produce" from 1 to 3 possible pages in Word from each record depending on the data in Excel file. That's why I have to "produce" all pages first and then to delete those which are not necessary. I tried to do it another way - I processed the Excel file 3 times and then I sorted the pages manually but in case of big files it is really a nuisance. The order of pages is important. I'll try to solve the problem continuing what I wrote in my prevoius news. I'll try not to center the first line however I don't understand why it worked when I processed it 3 times separately without the extra character. I don't know what causes the difference. Regards Tico Użytkownik "Graham Mayor" napisał w wiadomości ... I am totally bemused now. If you don't want the page(s) with this particular merge record, why are you merging the record in the first place? Wouldn't e.g. {SKIPIF {Mergefield Char} = "\"} work? -- Graham Mayor - Word MVP My web site www.gmayor.com Word MVP web site http://word.mvps.org Tico wrote: The same happens when I put in the Excel file "" instead of " " when I want a page not to be deleted. I think it is somehow connected with the sign of new page because sometimes it is OK but always after another sign of new page. However i don't know how to force a correct sign in the MaiMerge. Regards Tico Użytkownik "Tico" napisał w wiadomości ... I understand. I thought that everything was OK but I have one problem: the additional character damages to keeping a part of the first line in the center. I put in Excel file an addition column and the character "\" is put in it, if the page in Word should be deleted or the character " ", if the page in Word should'n be deleted. What is put : "\" or " " depends on other values in Excel file. Everything is OK but the first line on pages with " " is moved much more to the left than the 1 character (" ") should use (the same happens to pages with "\" but it is not important as they are deleted afterwards). The first line on each page consists of the constant text and a number that is put during the MailMerge process, like this ABCDEF GHIJ KLMNOP {MERGEFIELD No} The text should be in the center of the page, and the No on the right side. After I added the character it looks like this: {MERGEFIELD Char}ABCDEF GHIJ KLMNOP {MERGEFIELD No} (Before I put the additional character everything was OK and the constant text was in the center) My MailMerge "source" file consist of 5 pages, not just one. After the process of MailMerging I delete the "extra" pages using the macro from you. Each of the "source" 5 pages has similar first line as I described above. Could you help me once more, please? Regards Tico Użytkownik "Graham Mayor" napisał w wiadomości ... Page is a vague concept in Word which is not a page layout application and if you remove pages the document reflows to create a new 'page' structure. -- Graham Mayor - Word MVP My web site www.gmayor.com Word MVP web site http://word.mvps.org Tico wrote: Thank you both very, very much once again. I used the macro to the big MailMerge output file and it works perfectly. The macro would work faster if it could test just the first character on each page but I don't know how to change it. But it works very well and I am very grateful. As for a tutorial I expected something I had when I learnt other languages which began with "Hello World" or something like this. Then, step by step, it showed how to use more and more complicated language tools. Regards Tico Użytkownik "Graham Mayor" napisał w wiadomości ... If you are splitting the results of a mail merge, see http://www.gmayor.com/individual_merge_letters.htm As Doug says, the only way to learn vba is to put it to use to perform simple tasks and then get more adventurous. You can always use the macro recorder to give you some ideas. It is by no means perfect but it does help get you started. You will find lots of coding examples in the vba programming forums and on various web site, including my own. The vba help in Word 2007 is rather better than in earlier versions. -- Graham Mayor - Word MVP My web site www.gmayor.com Word MVP web site http://word.mvps.org Tico wrote: Thank you very, very much. I created a sample file and it works! Now I have to put the macro into my big file which is a result of MailMerge and make a lot of tests. By the way, I know almost nothing about VBA for Word. I looked at your page and I found a lot of interesting things there. However what I need most at the moment is any tutorial how to create simple macros in Word from the very beginning. Not just examples, which are important too, but first of all the most basic rules. I read that one of ways is to record macros using Word and then to analyse it in VBA Editor. I think that this can be useful later, when you know a lot, but not at the beginning. I am looking for any lessons, step by step showing what is neccessary in a macro and what it means. Then more and more functions to write working macros. Having such background I'll be able to learn using other methods. I tried to find anything like this in the Internet to download or use on line, but without any success. I found a lot for Excel but I read that the rules are not the same. Could you please advice me anything suitable for a person who is just starting with writing macros for Word? Thanks again for your help. Regards Tico Użytkownik "Graham Mayor" napisał w wiadomości ... The lines indicated in red have wrapped prematurely use the following which should not wrap Sub DeleteMarkedPages() Selection.HomeKey wdStory Selection.Find.ClearFormatting With Selection.Find Do While .Execute(findText:="\", _ MatchWildcards:=False, _ Wrap:=wdFindContinue, _ Forward:=True) = True Selection.Bookmarks("\page").Range.Delete Loop End With http://www.gmayor.com/installing_macro.htm The macro will remove any page with the \ character in Word 2007 and should work in Word 97 also, though I don't have it available to check. Word 2007 will open a Word document from Word 97 without the need to 'convert' it. -- Graham Mayor - Word MVP My web site www.gmayor.com Word MVP web site http://word.mvps.org Tico wrote: Thank you very much for your prompt reply. Unfortunately I don't know enough about macros to be able to use the macro. When I tried to use it I got the following lines in red: Do While .Execute(FindText:="#*#", MatchWildcards:=False, Wrap:=wdFindContinue, Forward:=True) = True Selection.Bookmarks("\page").Range.Delete regardless what I replaced the "#*#" with. My special character is \. I don't even know what I should writei n the macro: "#\#", "\" or simply \ I haven't found FindText in the "VBA for Dummies" for Office 97 that I have so I think I should save my file as Word 2007 first and then use the macro. I have Office 2007 (home edition) but I am not familiar with it yet, at least not to use macros. I am afraid I'll have to remove the pages manually. :-( Regards Tico Użytkownik "Doug Robbins - Word MVP" napisał w wiadomości ... Use a macro containing the following code where you replace the #*# with the special character that you intend to use. Selection.HomeKey wdStory Selection.Find.ClearFormatting With Selection.Find Do While .Execute(FindText:="#*#", MatchWildcards:=False, Wrap:=wdFindContinue, Forward:=True) = True Selection.Bookmarks("\page").Range.Delete Loop End With -- 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 "Tico" wrote in message ... Hi All, I have a big MS Word 97 file. I am looking for any method that let me remove automatically some pages which I can mark using, for example, a special character as the first on each page or in any other way. I would be also satisfied if I could automatically skip the pages whilst printing the file. I can use the MS Word 2007 to do it, if necessary. Could anyone help me please? The matter is urgent.:-) Regards Tico |
#15
Posted to microsoft.public.word.newusers
|
|||
|
|||
How to remove automatically some pages?
Sorry, I should have written 5 instead of 3 in my last news.
I have 5 kinds of pages however from each record only from 1 to 3 pages can be necessary. In "my" method I "produce" all 5 pages for each Excel record and then I delete unnecessary pages using tha macro from you. Sorting the pages manually I had to repeat the process 5 times however in this case I was able to produce only necessary pages using SKIPIF, of course. But sorting it manually is really a nuisance. I thought about using the "NEXT RECORD IF ..." but in this case I'd have to be able to skip pages in Word. :-( Probably the best way would be to write a "regular" program in Visual Basic or so, but unfortuantely I am not able to. Regards Tico Użytkownik "Tico" napisał w wiadomości ... No because SKIPIF cause to skip a whole record. But I have to "produce" from 1 to 3 possible pages in Word from each record depending on the data in Excel file. That's why I have to "produce" all pages first and then to delete those which are not necessary. I tried to do it another way - I processed the Excel file 3 times and then I sorted the pages manually but in case of big files it is really a nuisance. The order of pages is important. I'll try to solve the problem continuing what I wrote in my prevoius news. I'll try not to center the first line however I don't understand why it worked when I processed it 3 times separately without the extra character. I don't know what causes the difference. Regards Tico Użytkownik "Graham Mayor" napisał w wiadomości ... I am totally bemused now. If you don't want the page(s) with this particular merge record, why are you merging the record in the first place? Wouldn't e.g. {SKIPIF {Mergefield Char} = "\"} work? -- Graham Mayor - Word MVP My web site www.gmayor.com Word MVP web site http://word.mvps.org Tico wrote: The same happens when I put in the Excel file "" instead of " " when I want a page not to be deleted. I think it is somehow connected with the sign of new page because sometimes it is OK but always after another sign of new page. However i don't know how to force a correct sign in the MaiMerge. Regards Tico Użytkownik "Tico" napisał w wiadomości ... I understand. I thought that everything was OK but I have one problem: the additional character damages to keeping a part of the first line in the center. I put in Excel file an addition column and the character "\" is put in it, if the page in Word should be deleted or the character " ", if the page in Word should'n be deleted. What is put : "\" or " " depends on other values in Excel file. Everything is OK but the first line on pages with " " is moved much more to the left than the 1 character (" ") should use (the same happens to pages with "\" but it is not important as they are deleted afterwards). The first line on each page consists of the constant text and a number that is put during the MailMerge process, like this ABCDEF GHIJ KLMNOP {MERGEFIELD No} The text should be in the center of the page, and the No on the right side. After I added the character it looks like this: {MERGEFIELD Char}ABCDEF GHIJ KLMNOP {MERGEFIELD No} (Before I put the additional character everything was OK and the constant text was in the center) My MailMerge "source" file consist of 5 pages, not just one. After the process of MailMerging I delete the "extra" pages using the macro from you. Each of the "source" 5 pages has similar first line as I described above. Could you help me once more, please? Regards Tico Użytkownik "Graham Mayor" napisał w wiadomości ... Page is a vague concept in Word which is not a page layout application and if you remove pages the document reflows to create a new 'page' structure. -- Graham Mayor - Word MVP My web site www.gmayor.com Word MVP web site http://word.mvps.org Tico wrote: Thank you both very, very much once again. I used the macro to the big MailMerge output file and it works perfectly. The macro would work faster if it could test just the first character on each page but I don't know how to change it. But it works very well and I am very grateful. As for a tutorial I expected something I had when I learnt other languages which began with "Hello World" or something like this. Then, step by step, it showed how to use more and more complicated language tools. Regards Tico Użytkownik "Graham Mayor" napisał w wiadomości ... If you are splitting the results of a mail merge, see http://www.gmayor.com/individual_merge_letters.htm As Doug says, the only way to learn vba is to put it to use to perform simple tasks and then get more adventurous. You can always use the macro recorder to give you some ideas. It is by no means perfect but it does help get you started. You will find lots of coding examples in the vba programming forums and on various web site, including my own. The vba help in Word 2007 is rather better than in earlier versions. -- Graham Mayor - Word MVP My web site www.gmayor.com Word MVP web site http://word.mvps.org Tico wrote: Thank you very, very much. I created a sample file and it works! Now I have to put the macro into my big file which is a result of MailMerge and make a lot of tests. By the way, I know almost nothing about VBA for Word. I looked at your page and I found a lot of interesting things there. However what I need most at the moment is any tutorial how to create simple macros in Word from the very beginning. Not just examples, which are important too, but first of all the most basic rules. I read that one of ways is to record macros using Word and then to analyse it in VBA Editor. I think that this can be useful later, when you know a lot, but not at the beginning. I am looking for any lessons, step by step showing what is neccessary in a macro and what it means. Then more and more functions to write working macros. Having such background I'll be able to learn using other methods. I tried to find anything like this in the Internet to download or use on line, but without any success. I found a lot for Excel but I read that the rules are not the same. Could you please advice me anything suitable for a person who is just starting with writing macros for Word? Thanks again for your help. Regards Tico Użytkownik "Graham Mayor" napisał w wiadomości ... The lines indicated in red have wrapped prematurely use the following which should not wrap Sub DeleteMarkedPages() Selection.HomeKey wdStory Selection.Find.ClearFormatting With Selection.Find Do While .Execute(findText:="\", _ MatchWildcards:=False, _ Wrap:=wdFindContinue, _ Forward:=True) = True Selection.Bookmarks("\page").Range.Delete Loop End With http://www.gmayor.com/installing_macro.htm The macro will remove any page with the \ character in Word 2007 and should work in Word 97 also, though I don't have it available to check. Word 2007 will open a Word document from Word 97 without the need to 'convert' it. -- Graham Mayor - Word MVP My web site www.gmayor.com Word MVP web site http://word.mvps.org Tico wrote: Thank you very much for your prompt reply. Unfortunately I don't know enough about macros to be able to use the macro. When I tried to use it I got the following lines in red: Do While .Execute(FindText:="#*#", MatchWildcards:=False, Wrap:=wdFindContinue, Forward:=True) = True Selection.Bookmarks("\page").Range.Delete regardless what I replaced the "#*#" with. My special character is \. I don't even know what I should writei n the macro: "#\#", "\" or simply \ I haven't found FindText in the "VBA for Dummies" for Office 97 that I have so I think I should save my file as Word 2007 first and then use the macro. I have Office 2007 (home edition) but I am not familiar with it yet, at least not to use macros. I am afraid I'll have to remove the pages manually. :-( Regards Tico Użytkownik "Doug Robbins - Word MVP" napisał w wiadomości ... Use a macro containing the following code where you replace the #*# with the special character that you intend to use. Selection.HomeKey wdStory Selection.Find.ClearFormatting With Selection.Find Do While .Execute(FindText:="#*#", MatchWildcards:=False, Wrap:=wdFindContinue, Forward:=True) = True Selection.Bookmarks("\page").Range.Delete Loop End With -- 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 "Tico" wrote in message ... Hi All, I have a big MS Word 97 file. I am looking for any method that let me remove automatically some pages which I can mark using, for example, a special character as the first on each page or in any other way. I would be also satisfied if I could automatically skip the pages whilst printing the file. I can use the MS Word 2007 to do it, if necessary. Could anyone help me please? The matter is urgent.:-) Regards Tico |
#16
Posted to microsoft.public.word.newusers
|
|||
|
|||
How to remove automatically some pages?
From your description you should conditionally insert the pages eg
{IF {Mergefield Char} "\" "{IncludeText c:\\path\\page1.doc"}" ""} It is always easier not to add in the pages that you don't need than to remove them later -- Graham Mayor - Word MVP My web site www.gmayor.com Word MVP web site http://word.mvps.org Tico wrote: Sorry, I should have written 5 instead of 3 in my last news. I have 5 kinds of pages however from each record only from 1 to 3 pages can be necessary. In "my" method I "produce" all 5 pages for each Excel record and then I delete unnecessary pages using tha macro from you. Sorting the pages manually I had to repeat the process 5 times however in this case I was able to produce only necessary pages using SKIPIF, of course. But sorting it manually is really a nuisance. I thought about using the "NEXT RECORD IF ..." but in this case I'd have to be able to skip pages in Word. :-( Probably the best way would be to write a "regular" program in Visual Basic or so, but unfortuantely I am not able to. Regards Tico Użytkownik "Tico" napisał w wiadomości ... No because SKIPIF cause to skip a whole record. But I have to "produce" from 1 to 3 possible pages in Word from each record depending on the data in Excel file. That's why I have to "produce" all pages first and then to delete those which are not necessary. I tried to do it another way - I processed the Excel file 3 times and then I sorted the pages manually but in case of big files it is really a nuisance. The order of pages is important. I'll try to solve the problem continuing what I wrote in my prevoius news. I'll try not to center the first line however I don't understand why it worked when I processed it 3 times separately without the extra character. I don't know what causes the difference. Regards Tico Użytkownik "Graham Mayor" napisał w wiadomości ... I am totally bemused now. If you don't want the page(s) with this particular merge record, why are you merging the record in the first place? Wouldn't e.g. {SKIPIF {Mergefield Char} = "\"} work? -- Graham Mayor - Word MVP My web site www.gmayor.com Word MVP web site http://word.mvps.org Tico wrote: The same happens when I put in the Excel file "" instead of " " when I want a page not to be deleted. I think it is somehow connected with the sign of new page because sometimes it is OK but always after another sign of new page. However i don't know how to force a correct sign in the MaiMerge. Regards Tico Użytkownik "Tico" napisał w wiadomości ... I understand. I thought that everything was OK but I have one problem: the additional character damages to keeping a part of the first line in the center. I put in Excel file an addition column and the character "\" is put in it, if the page in Word should be deleted or the character " ", if the page in Word should'n be deleted. What is put : "\" or " " depends on other values in Excel file. Everything is OK but the first line on pages with " " is moved much more to the left than the 1 character (" ") should use (the same happens to pages with "\" but it is not important as they are deleted afterwards). The first line on each page consists of the constant text and a number that is put during the MailMerge process, like this ABCDEF GHIJ KLMNOP {MERGEFIELD No} The text should be in the center of the page, and the No on the right side. After I added the character it looks like this: {MERGEFIELD Char}ABCDEF GHIJ KLMNOP {MERGEFIELD No} (Before I put the additional character everything was OK and the constant text was in the center) My MailMerge "source" file consist of 5 pages, not just one. After the process of MailMerging I delete the "extra" pages using the macro from you. Each of the "source" 5 pages has similar first line as I described above. Could you help me once more, please? Regards Tico Użytkownik "Graham Mayor" napisał w wiadomości ... Page is a vague concept in Word which is not a page layout application and if you remove pages the document reflows to create a new 'page' structure. -- Graham Mayor - Word MVP My web site www.gmayor.com Word MVP web site http://word.mvps.org Tico wrote: Thank you both very, very much once again. I used the macro to the big MailMerge output file and it works perfectly. The macro would work faster if it could test just the first character on each page but I don't know how to change it. But it works very well and I am very grateful. As for a tutorial I expected something I had when I learnt other languages which began with "Hello World" or something like this. Then, step by step, it showed how to use more and more complicated language tools. Regards Tico Użytkownik "Graham Mayor" napisał w wiadomości ... If you are splitting the results of a mail merge, see http://www.gmayor.com/individual_merge_letters.htm As Doug says, the only way to learn vba is to put it to use to perform simple tasks and then get more adventurous. You can always use the macro recorder to give you some ideas. It is by no means perfect but it does help get you started. You will find lots of coding examples in the vba programming forums and on various web site, including my own. The vba help in Word 2007 is rather better than in earlier versions. -- Graham Mayor - Word MVP My web site www.gmayor.com Word MVP web site http://word.mvps.org Tico wrote: Thank you very, very much. I created a sample file and it works! Now I have to put the macro into my big file which is a result of MailMerge and make a lot of tests. By the way, I know almost nothing about VBA for Word. I looked at your page and I found a lot of interesting things there. However what I need most at the moment is any tutorial how to create simple macros in Word from the very beginning. Not just examples, which are important too, but first of all the most basic rules. I read that one of ways is to record macros using Word and then to analyse it in VBA Editor. I think that this can be useful later, when you know a lot, but not at the beginning. I am looking for any lessons, step by step showing what is neccessary in a macro and what it means. Then more and more functions to write working macros. Having such background I'll be able to learn using other methods. I tried to find anything like this in the Internet to download or use on line, but without any success. I found a lot for Excel but I read that the rules are not the same. Could you please advice me anything suitable for a person who is just starting with writing macros for Word? Thanks again for your help. Regards Tico Użytkownik "Graham Mayor" napisał w wiadomości ... The lines indicated in red have wrapped prematurely use the following which should not wrap Sub DeleteMarkedPages() Selection.HomeKey wdStory Selection.Find.ClearFormatting With Selection.Find Do While .Execute(findText:="\", _ MatchWildcards:=False, _ Wrap:=wdFindContinue, _ Forward:=True) = True Selection.Bookmarks("\page").Range.Delete Loop End With http://www.gmayor.com/installing_macro.htm The macro will remove any page with the \ character in Word 2007 and should work in Word 97 also, though I don't have it available to check. Word 2007 will open a Word document from Word 97 without the need to 'convert' it. -- Graham Mayor - Word MVP My web site www.gmayor.com Word MVP web site http://word.mvps.org Tico wrote: Thank you very much for your prompt reply. Unfortunately I don't know enough about macros to be able to use the macro. When I tried to use it I got the following lines in red: Do While .Execute(FindText:="#*#", MatchWildcards:=False, Wrap:=wdFindContinue, Forward:=True) = True Selection.Bookmarks("\page").Range.Delete regardless what I replaced the "#*#" with. My special character is \. I don't even know what I should writei n the macro: "#\#", "\" or simply \ I haven't found FindText in the "VBA for Dummies" for Office 97 that I have so I think I should save my file as Word 2007 first and then use the macro. I have Office 2007 (home edition) but I am not familiar with it yet, at least not to use macros. I am afraid I'll have to remove the pages manually. :-( Regards Tico Użytkownik "Doug Robbins - Word MVP" napisał w wiadomości ... Use a macro containing the following code where you replace the #*# with the special character that you intend to use. Selection.HomeKey wdStory Selection.Find.ClearFormatting With Selection.Find Do While .Execute(FindText:="#*#", MatchWildcards:=False, Wrap:=wdFindContinue, Forward:=True) = True Selection.Bookmarks("\page").Range.Delete Loop End With -- 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 "Tico" wrote in message ... Hi All, I have a big MS Word 97 file. I am looking for any method that let me remove automatically some pages which I can mark using, for example, a special character as the first on each page or in any other way. I would be also satisfied if I could automatically skip the pages whilst printing the file. I can use the MS Word 2007 to do it, if necessary. Could anyone help me please? The matter is urgent.:-) Regards Tico |
#17
Posted to microsoft.public.word.newusers
|
|||
|
|||
How to remove automatically some pages?
I am not sure if I understand you well.
Do you mean to process for each kind of page separately (as I described in the method with sorting manually) and then to process the MailMerge again just to combine the pages into one file in a proper order? Regards Tico Użytkownik "Graham Mayor" napisał w wiadomości ... From your description you should conditionally insert the pages eg {IF {Mergefield Char} "\" "{IncludeText c:\\path\\page1.doc"}" ""} It is always easier not to add in the pages that you don't need than to remove them later -- Graham Mayor - Word MVP My web site www.gmayor.com Word MVP web site http://word.mvps.org Tico wrote: Sorry, I should have written 5 instead of 3 in my last news. I have 5 kinds of pages however from each record only from 1 to 3 pages can be necessary. In "my" method I "produce" all 5 pages for each Excel record and then I delete unnecessary pages using tha macro from you. Sorting the pages manually I had to repeat the process 5 times however in this case I was able to produce only necessary pages using SKIPIF, of course. But sorting it manually is really a nuisance. I thought about using the "NEXT RECORD IF ..." but in this case I'd have to be able to skip pages in Word. :-( Probably the best way would be to write a "regular" program in Visual Basic or so, but unfortuantely I am not able to. Regards Tico Użytkownik "Tico" napisał w wiadomości ... No because SKIPIF cause to skip a whole record. But I have to "produce" from 1 to 3 possible pages in Word from each record depending on the data in Excel file. That's why I have to "produce" all pages first and then to delete those which are not necessary. I tried to do it another way - I processed the Excel file 3 times and then I sorted the pages manually but in case of big files it is really a nuisance. The order of pages is important. I'll try to solve the problem continuing what I wrote in my prevoius news. I'll try not to center the first line however I don't understand why it worked when I processed it 3 times separately without the extra character. I don't know what causes the difference. Regards Tico Użytkownik "Graham Mayor" napisał w wiadomości ... I am totally bemused now. If you don't want the page(s) with this particular merge record, why are you merging the record in the first place? Wouldn't e.g. {SKIPIF {Mergefield Char} = "\"} work? -- Graham Mayor - Word MVP My web site www.gmayor.com Word MVP web site http://word.mvps.org Tico wrote: The same happens when I put in the Excel file "" instead of " " when I want a page not to be deleted. I think it is somehow connected with the sign of new page because sometimes it is OK but always after another sign of new page. However i don't know how to force a correct sign in the MaiMerge. Regards Tico Użytkownik "Tico" napisał w wiadomości ... I understand. I thought that everything was OK but I have one problem: the additional character damages to keeping a part of the first line in the center. I put in Excel file an addition column and the character "\" is put in it, if the page in Word should be deleted or the character " ", if the page in Word should'n be deleted. What is put : "\" or " " depends on other values in Excel file. Everything is OK but the first line on pages with " " is moved much more to the left than the 1 character (" ") should use (the same happens to pages with "\" but it is not important as they are deleted afterwards). The first line on each page consists of the constant text and a number that is put during the MailMerge process, like this ABCDEF GHIJ KLMNOP {MERGEFIELD No} The text should be in the center of the page, and the No on the right side. After I added the character it looks like this: {MERGEFIELD Char}ABCDEF GHIJ KLMNOP {MERGEFIELD No} (Before I put the additional character everything was OK and the constant text was in the center) My MailMerge "source" file consist of 5 pages, not just one. After the process of MailMerging I delete the "extra" pages using the macro from you. Each of the "source" 5 pages has similar first line as I described above. Could you help me once more, please? Regards Tico Użytkownik "Graham Mayor" napisał w wiadomości ... Page is a vague concept in Word which is not a page layout application and if you remove pages the document reflows to create a new 'page' structure. -- Graham Mayor - Word MVP My web site www.gmayor.com Word MVP web site http://word.mvps.org Tico wrote: Thank you both very, very much once again. I used the macro to the big MailMerge output file and it works perfectly. The macro would work faster if it could test just the first character on each page but I don't know how to change it. But it works very well and I am very grateful. As for a tutorial I expected something I had when I learnt other languages which began with "Hello World" or something like this. Then, step by step, it showed how to use more and more complicated language tools. Regards Tico Użytkownik "Graham Mayor" napisał w wiadomości ... If you are splitting the results of a mail merge, see http://www.gmayor.com/individual_merge_letters.htm As Doug says, the only way to learn vba is to put it to use to perform simple tasks and then get more adventurous. You can always use the macro recorder to give you some ideas. It is by no means perfect but it does help get you started. You will find lots of coding examples in the vba programming forums and on various web site, including my own. The vba help in Word 2007 is rather better than in earlier versions. -- Graham Mayor - Word MVP My web site www.gmayor.com Word MVP web site http://word.mvps.org Tico wrote: Thank you very, very much. I created a sample file and it works! Now I have to put the macro into my big file which is a result of MailMerge and make a lot of tests. By the way, I know almost nothing about VBA for Word. I looked at your page and I found a lot of interesting things there. However what I need most at the moment is any tutorial how to create simple macros in Word from the very beginning. Not just examples, which are important too, but first of all the most basic rules. I read that one of ways is to record macros using Word and then to analyse it in VBA Editor. I think that this can be useful later, when you know a lot, but not at the beginning. I am looking for any lessons, step by step showing what is neccessary in a macro and what it means. Then more and more functions to write working macros. Having such background I'll be able to learn using other methods. I tried to find anything like this in the Internet to download or use on line, but without any success. I found a lot for Excel but I read that the rules are not the same. Could you please advice me anything suitable for a person who is just starting with writing macros for Word? Thanks again for your help. Regards Tico Użytkownik "Graham Mayor" napisał w wiadomości ... The lines indicated in red have wrapped prematurely use the following which should not wrap Sub DeleteMarkedPages() Selection.HomeKey wdStory Selection.Find.ClearFormatting With Selection.Find Do While .Execute(findText:="\", _ MatchWildcards:=False, _ Wrap:=wdFindContinue, _ Forward:=True) = True Selection.Bookmarks("\page").Range.Delete Loop End With http://www.gmayor.com/installing_macro.htm The macro will remove any page with the \ character in Word 2007 and should work in Word 97 also, though I don't have it available to check. Word 2007 will open a Word document from Word 97 without the need to 'convert' it. -- Graham Mayor - Word MVP My web site www.gmayor.com Word MVP web site http://word.mvps.org Tico wrote: Thank you very much for your prompt reply. Unfortunately I don't know enough about macros to be able to use the macro. When I tried to use it I got the following lines in red: Do While .Execute(FindText:="#*#", MatchWildcards:=False, Wrap:=wdFindContinue, Forward:=True) = True Selection.Bookmarks("\page").Range.Delete regardless what I replaced the "#*#" with. My special character is \. I don't even know what I should writei n the macro: "#\#", "\" or simply \ I haven't found FindText in the "VBA for Dummies" for Office 97 that I have so I think I should save my file as Word 2007 first and then use the macro. I have Office 2007 (home edition) but I am not familiar with it yet, at least not to use macros. I am afraid I'll have to remove the pages manually. :-( Regards Tico Użytkownik "Doug Robbins - Word MVP" napisał w wiadomości ... Use a macro containing the following code where you replace the #*# with the special character that you intend to use. Selection.HomeKey wdStory Selection.Find.ClearFormatting With Selection.Find Do While .Execute(FindText:="#*#", MatchWildcards:=False, Wrap:=wdFindContinue, Forward:=True) = True Selection.Bookmarks("\page").Range.Delete Loop End With -- 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 "Tico" wrote in message ... Hi All, I have a big MS Word 97 file. I am looking for any method that let me remove automatically some pages which I can mark using, for example, a special character as the first on each page or in any other way. I would be also satisfied if I could automatically skip the pages whilst printing the file. I can use the MS Word 2007 to do it, if necessary. Could anyone help me please? The matter is urgent.:-) Regards Tico |
#18
Posted to microsoft.public.word.newusers
|
|||
|
|||
How to remove automatically some pages?
You claim your merge requires a number of pages according to the data.
Instead of merging all the pages and deleting the unwanted ones, include only the ones you need according to the requirements of the data ie save each page as a separate document and use includetext to insert only the pages you want. -- Graham Mayor - Word MVP My web site www.gmayor.com Word MVP web site http://word.mvps.org Tico wrote: I am not sure if I understand you well. Do you mean to process for each kind of page separately (as I described in the method with sorting manually) and then to process the MailMerge again just to combine the pages into one file in a proper order? Regards Tico Użytkownik "Graham Mayor" napisał w wiadomości ... From your description you should conditionally insert the pages eg {IF {Mergefield Char} "\" "{IncludeText c:\\path\\page1.doc"}" ""} It is always easier not to add in the pages that you don't need than to remove them later -- Graham Mayor - Word MVP My web site www.gmayor.com Word MVP web site http://word.mvps.org Tico wrote: Sorry, I should have written 5 instead of 3 in my last news. I have 5 kinds of pages however from each record only from 1 to 3 pages can be necessary. In "my" method I "produce" all 5 pages for each Excel record and then I delete unnecessary pages using tha macro from you. Sorting the pages manually I had to repeat the process 5 times however in this case I was able to produce only necessary pages using SKIPIF, of course. But sorting it manually is really a nuisance. I thought about using the "NEXT RECORD IF ..." but in this case I'd have to be able to skip pages in Word. :-( Probably the best way would be to write a "regular" program in Visual Basic or so, but unfortuantely I am not able to. Regards Tico Użytkownik "Tico" napisał w wiadomości ... No because SKIPIF cause to skip a whole record. But I have to "produce" from 1 to 3 possible pages in Word from each record depending on the data in Excel file. That's why I have to "produce" all pages first and then to delete those which are not necessary. I tried to do it another way - I processed the Excel file 3 times and then I sorted the pages manually but in case of big files it is really a nuisance. The order of pages is important. I'll try to solve the problem continuing what I wrote in my prevoius news. I'll try not to center the first line however I don't understand why it worked when I processed it 3 times separately without the extra character. I don't know what causes the difference. Regards Tico Użytkownik "Graham Mayor" napisał w wiadomości ... I am totally bemused now. If you don't want the page(s) with this particular merge record, why are you merging the record in the first place? Wouldn't e.g. {SKIPIF {Mergefield Char} = "\"} work? -- Graham Mayor - Word MVP My web site www.gmayor.com Word MVP web site http://word.mvps.org Tico wrote: The same happens when I put in the Excel file "" instead of " " when I want a page not to be deleted. I think it is somehow connected with the sign of new page because sometimes it is OK but always after another sign of new page. However i don't know how to force a correct sign in the MaiMerge. Regards Tico Użytkownik "Tico" napisał w wiadomości ... I understand. I thought that everything was OK but I have one problem: the additional character damages to keeping a part of the first line in the center. I put in Excel file an addition column and the character "\" is put in it, if the page in Word should be deleted or the character " ", if the page in Word should'n be deleted. What is put : "\" or " " depends on other values in Excel file. Everything is OK but the first line on pages with " " is moved much more to the left than the 1 character (" ") should use (the same happens to pages with "\" but it is not important as they are deleted afterwards). The first line on each page consists of the constant text and a number that is put during the MailMerge process, like this ABCDEF GHIJ KLMNOP {MERGEFIELD No} The text should be in the center of the page, and the No on the right side. After I added the character it looks like this: {MERGEFIELD Char}ABCDEF GHIJ KLMNOP {MERGEFIELD No} (Before I put the additional character everything was OK and the constant text was in the center) My MailMerge "source" file consist of 5 pages, not just one. After the process of MailMerging I delete the "extra" pages using the macro from you. Each of the "source" 5 pages has similar first line as I described above. Could you help me once more, please? Regards Tico Użytkownik "Graham Mayor" napisał w wiadomości ... Page is a vague concept in Word which is not a page layout application and if you remove pages the document reflows to create a new 'page' structure. -- Graham Mayor - Word MVP My web site www.gmayor.com Word MVP web site http://word.mvps.org Tico wrote: Thank you both very, very much once again. I used the macro to the big MailMerge output file and it works perfectly. The macro would work faster if it could test just the first character on each page but I don't know how to change it. But it works very well and I am very grateful. As for a tutorial I expected something I had when I learnt other languages which began with "Hello World" or something like this. Then, step by step, it showed how to use more and more complicated language tools. Regards Tico Użytkownik "Graham Mayor" napisał w wiadomości ... If you are splitting the results of a mail merge, see http://www.gmayor.com/individual_merge_letters.htm As Doug says, the only way to learn vba is to put it to use to perform simple tasks and then get more adventurous. You can always use the macro recorder to give you some ideas. It is by no means perfect but it does help get you started. You will find lots of coding examples in the vba programming forums and on various web site, including my own. The vba help in Word 2007 is rather better than in earlier versions. -- Graham Mayor - Word MVP My web site www.gmayor.com Word MVP web site http://word.mvps.org Tico wrote: Thank you very, very much. I created a sample file and it works! Now I have to put the macro into my big file which is a result of MailMerge and make a lot of tests. By the way, I know almost nothing about VBA for Word. I looked at your page and I found a lot of interesting things there. However what I need most at the moment is any tutorial how to create simple macros in Word from the very beginning. Not just examples, which are important too, but first of all the most basic rules. I read that one of ways is to record macros using Word and then to analyse it in VBA Editor. I think that this can be useful later, when you know a lot, but not at the beginning. I am looking for any lessons, step by step showing what is neccessary in a macro and what it means. Then more and more functions to write working macros. Having such background I'll be able to learn using other methods. I tried to find anything like this in the Internet to download or use on line, but without any success. I found a lot for Excel but I read that the rules are not the same. Could you please advice me anything suitable for a person who is just starting with writing macros for Word? Thanks again for your help. Regards Tico Użytkownik "Graham Mayor" napisał w wiadomości ... The lines indicated in red have wrapped prematurely use the following which should not wrap Sub DeleteMarkedPages() Selection.HomeKey wdStory Selection.Find.ClearFormatting With Selection.Find Do While .Execute(findText:="\", _ MatchWildcards:=False, _ Wrap:=wdFindContinue, _ Forward:=True) = True Selection.Bookmarks("\page").Range.Delete Loop End With http://www.gmayor.com/installing_macro.htm The macro will remove any page with the \ character in Word 2007 and should work in Word 97 also, though I don't have it available to check. Word 2007 will open a Word document from Word 97 without the need to 'convert' it. -- Graham Mayor - Word MVP My web site www.gmayor.com Word MVP web site http://word.mvps.org Tico wrote: Thank you very much for your prompt reply. Unfortunately I don't know enough about macros to be able to use the macro. When I tried to use it I got the following lines in red: Do While .Execute(FindText:="#*#", MatchWildcards:=False, Wrap:=wdFindContinue, Forward:=True) = True Selection.Bookmarks("\page").Range.Delete regardless what I replaced the "#*#" with. My special character is \. I don't even know what I should writei n the macro: "#\#", "\" or simply \ I haven't found FindText in the "VBA for Dummies" for Office 97 that I have so I think I should save my file as Word 2007 first and then use the macro. I have Office 2007 (home edition) but I am not familiar with it yet, at least not to use macros. I am afraid I'll have to remove the pages manually. :-( Regards Tico Użytkownik "Doug Robbins - Word MVP" napisał w wiadomości ... Use a macro containing the following code where you replace the #*# with the special character that you intend to use. Selection.HomeKey wdStory Selection.Find.ClearFormatting With Selection.Find Do While .Execute(FindText:="#*#", MatchWildcards:=False, Wrap:=wdFindContinue, Forward:=True) = True Selection.Bookmarks("\page").Range.Delete Loop End With -- 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 "Tico" wrote in message ... Hi All, I have a big MS Word 97 file. I am looking for any method that let me remove automatically some pages which I can mark using, for example, a special character as the first on each page or in any other way. I would be also satisfied if I could automatically skip the pages whilst printing the file. I can use the MS Word 2007 to do it, if necessary. Could anyone help me please? The matter is urgent.:-) Regards Tico |
#19
Posted to microsoft.public.word.newusers
|
|||
|
|||
How to remove automatically some pages?
That's what I meant.
But I must make any mistake because I got: {IF "\" "{IncludeText c: page1.doc"}" ""} {IF \ "\" "{IncludeText c: page2.doc"}" ""} {IF \ "\" "{IncludeText c: page3.doc "}" ""} {IF \ "\" "{IncludeText c: page4.doc "}" ""} {IF \ "\" "{IncludeText c: page5.doc "}" ""} ================ next page ============== {IF "\" "{IncludeText c: page1.doc"}" ""} {IF \ "\" "{IncludeText c: page2.doc"}" ""} {IF \ "\" "{IncludeText c: page3.doc "}" ""} {IF \ "\" "{IncludeText c: page4.doc "}" ""} {IF \ "\" "{IncludeText c: page5.doc "}" ""} etc. n times, where n is the numer of rows in Excel files. I must admin that I never used MailMerge this way so probably I don't know about anything important. First of all I don't understand why in this method just 1 page from the file page1.doc or page2.doc etc is included in the output file. Regards Tico Użytkownik "Graham Mayor" napisał w wiadomości ... You claim your merge requires a number of pages according to the data. Instead of merging all the pages and deleting the unwanted ones, include only the ones you need according to the requirements of the data ie save each page as a separate document and use includetext to insert only the pages you want. -- Graham Mayor - Word MVP My web site www.gmayor.com Word MVP web site http://word.mvps.org Tico wrote: I am not sure if I understand you well. Do you mean to process for each kind of page separately (as I described in the method with sorting manually) and then to process the MailMerge again just to combine the pages into one file in a proper order? Regards Tico Użytkownik "Graham Mayor" napisał w wiadomości ... From your description you should conditionally insert the pages eg {IF {Mergefield Char} "\" "{IncludeText c:\\path\\page1.doc"}" ""} It is always easier not to add in the pages that you don't need than to remove them later -- Graham Mayor - Word MVP My web site www.gmayor.com Word MVP web site http://word.mvps.org Tico wrote: Sorry, I should have written 5 instead of 3 in my last news. I have 5 kinds of pages however from each record only from 1 to 3 pages can be necessary. In "my" method I "produce" all 5 pages for each Excel record and then I delete unnecessary pages using tha macro from you. Sorting the pages manually I had to repeat the process 5 times however in this case I was able to produce only necessary pages using SKIPIF, of course. But sorting it manually is really a nuisance. I thought about using the "NEXT RECORD IF ..." but in this case I'd have to be able to skip pages in Word. :-( Probably the best way would be to write a "regular" program in Visual Basic or so, but unfortuantely I am not able to. Regards Tico Użytkownik "Tico" napisał w wiadomości ... No because SKIPIF cause to skip a whole record. But I have to "produce" from 1 to 3 possible pages in Word from each record depending on the data in Excel file. That's why I have to "produce" all pages first and then to delete those which are not necessary. I tried to do it another way - I processed the Excel file 3 times and then I sorted the pages manually but in case of big files it is really a nuisance. The order of pages is important. I'll try to solve the problem continuing what I wrote in my prevoius news. I'll try not to center the first line however I don't understand why it worked when I processed it 3 times separately without the extra character. I don't know what causes the difference. Regards Tico Użytkownik "Graham Mayor" napisał w wiadomości ... I am totally bemused now. If you don't want the page(s) with this particular merge record, why are you merging the record in the first place? Wouldn't e.g. {SKIPIF {Mergefield Char} = "\"} work? -- Graham Mayor - Word MVP My web site www.gmayor.com Word MVP web site http://word.mvps.org Tico wrote: The same happens when I put in the Excel file "" instead of " " when I want a page not to be deleted. I think it is somehow connected with the sign of new page because sometimes it is OK but always after another sign of new page. However i don't know how to force a correct sign in the MaiMerge. Regards Tico Użytkownik "Tico" napisał w wiadomości ... I understand. I thought that everything was OK but I have one problem: the additional character damages to keeping a part of the first line in the center. I put in Excel file an addition column and the character "\" is put in it, if the page in Word should be deleted or the character " ", if the page in Word should'n be deleted. What is put : "\" or " " depends on other values in Excel file. Everything is OK but the first line on pages with " " is moved much more to the left than the 1 character (" ") should use (the same happens to pages with "\" but it is not important as they are deleted afterwards). The first line on each page consists of the constant text and a number that is put during the MailMerge process, like this ABCDEF GHIJ KLMNOP {MERGEFIELD No} The text should be in the center of the page, and the No on the right side. After I added the character it looks like this: {MERGEFIELD Char}ABCDEF GHIJ KLMNOP {MERGEFIELD No} (Before I put the additional character everything was OK and the constant text was in the center) My MailMerge "source" file consist of 5 pages, not just one. After the process of MailMerging I delete the "extra" pages using the macro from you. Each of the "source" 5 pages has similar first line as I described above. Could you help me once more, please? Regards Tico Użytkownik "Graham Mayor" napisał w wiadomości ... Page is a vague concept in Word which is not a page layout application and if you remove pages the document reflows to create a new 'page' structure. -- Graham Mayor - Word MVP My web site www.gmayor.com Word MVP web site http://word.mvps.org Tico wrote: Thank you both very, very much once again. I used the macro to the big MailMerge output file and it works perfectly. The macro would work faster if it could test just the first character on each page but I don't know how to change it. But it works very well and I am very grateful. As for a tutorial I expected something I had when I learnt other languages which began with "Hello World" or something like this. Then, step by step, it showed how to use more and more complicated language tools. Regards Tico Użytkownik "Graham Mayor" napisał w wiadomości ... If you are splitting the results of a mail merge, see http://www.gmayor.com/individual_merge_letters.htm As Doug says, the only way to learn vba is to put it to use to perform simple tasks and then get more adventurous. You can always use the macro recorder to give you some ideas. It is by no means perfect but it does help get you started. You will find lots of coding examples in the vba programming forums and on various web site, including my own. The vba help in Word 2007 is rather better than in earlier versions. -- Graham Mayor - Word MVP My web site www.gmayor.com Word MVP web site http://word.mvps.org Tico wrote: Thank you very, very much. I created a sample file and it works! Now I have to put the macro into my big file which is a result of MailMerge and make a lot of tests. By the way, I know almost nothing about VBA for Word. I looked at your page and I found a lot of interesting things there. However what I need most at the moment is any tutorial how to create simple macros in Word from the very beginning. Not just examples, which are important too, but first of all the most basic rules. I read that one of ways is to record macros using Word and then to analyse it in VBA Editor. I think that this can be useful later, when you know a lot, but not at the beginning. I am looking for any lessons, step by step showing what is neccessary in a macro and what it means. Then more and more functions to write working macros. Having such background I'll be able to learn using other methods. I tried to find anything like this in the Internet to download or use on line, but without any success. I found a lot for Excel but I read that the rules are not the same. Could you please advice me anything suitable for a person who is just starting with writing macros for Word? Thanks again for your help. Regards Tico Użytkownik "Graham Mayor" napisał w wiadomości ... The lines indicated in red have wrapped prematurely use the following which should not wrap Sub DeleteMarkedPages() Selection.HomeKey wdStory Selection.Find.ClearFormatting With Selection.Find Do While .Execute(findText:="\", _ MatchWildcards:=False, _ Wrap:=wdFindContinue, _ Forward:=True) = True Selection.Bookmarks("\page").Range.Delete Loop End With http://www.gmayor.com/installing_macro.htm The macro will remove any page with the \ character in Word 2007 and should work in Word 97 also, though I don't have it available to check. Word 2007 will open a Word document from Word 97 without the need to 'convert' it. -- Graham Mayor - Word MVP My web site www.gmayor.com Word MVP web site http://word.mvps.org Tico wrote: Thank you very much for your prompt reply. Unfortunately I don't know enough about macros to be able to use the macro. When I tried to use it I got the following lines in red: Do While .Execute(FindText:="#*#", MatchWildcards:=False, Wrap:=wdFindContinue, Forward:=True) = True Selection.Bookmarks("\page").Range.Delete regardless what I replaced the "#*#" with. My special character is \. I don't even know what I should writei n the macro: "#\#", "\" or simply \ I haven't found FindText in the "VBA for Dummies" for Office 97 that I have so I think I should save my file as Word 2007 first and then use the macro. I have Office 2007 (home edition) but I am not familiar with it yet, at least not to use macros. I am afraid I'll have to remove the pages manually. :-( Regards Tico Użytkownik "Doug Robbins - Word MVP" napisał w wiadomości ... Use a macro containing the following code where you replace the #*# with the special character that you intend to use. Selection.HomeKey wdStory Selection.Find.ClearFormatting With Selection.Find Do While .Execute(FindText:="#*#", MatchWildcards:=False, Wrap:=wdFindContinue, Forward:=True) = True Selection.Bookmarks("\page").Range.Delete Loop End With -- 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 "Tico" wrote in message ... Hi All, I have a big MS Word 97 file. I am looking for any method that let me remove automatically some pages which I can mark using, for example, a special character as the first on each page or in any other way. I would be also satisfied if I could automatically skip the pages whilst printing the file. I can use the MS Word 2007 to do it, if necessary. Could anyone help me please? The matter is urgent.:-) Regards Tico |
#20
Posted to microsoft.public.word.newusers
|
|||
|
|||
How to remove automatically some pages?
My input ("source") file looked as follows:
{IF {MERGEFIELD I} "\" "{IncludeText c: page1.doc"}" ""} {IF {MERGEFIELD II} "\" "{IncludeText c: page2.doc"}" ""} {IF {MERGEFIELD III} "\" "{IncludeText c: page3.doc "}" ""} {IF {MERGEFIELD IV} "\" "{IncludeText c: page4.doc "}" ""} {IF {MERGEFIELD V} "\" "{IncludeText c: page5.doc "}" ""} Tico Użytkownik "Tico" napisał w wiadomości ... That's what I meant. But I must make any mistake because I got: {IF "\" "{IncludeText c: page1.doc"}" ""} {IF \ "\" "{IncludeText c: page2.doc"}" ""} {IF \ "\" "{IncludeText c: page3.doc "}" ""} {IF \ "\" "{IncludeText c: page4.doc "}" ""} {IF \ "\" "{IncludeText c: page5.doc "}" ""} ================ next page ============== {IF "\" "{IncludeText c: page1.doc"}" ""} {IF \ "\" "{IncludeText c: page2.doc"}" ""} {IF \ "\" "{IncludeText c: page3.doc "}" ""} {IF \ "\" "{IncludeText c: page4.doc "}" ""} {IF \ "\" "{IncludeText c: page5.doc "}" ""} etc. n times, where n is the numer of rows in Excel files. I must admin that I never used MailMerge this way so probably I don't know about anything important. First of all I don't understand why in this method just 1 page from the file page1.doc or page2.doc etc is included in the output file. Regards Tico Użytkownik "Graham Mayor" napisał w wiadomości ... You claim your merge requires a number of pages according to the data. Instead of merging all the pages and deleting the unwanted ones, include only the ones you need according to the requirements of the data ie save each page as a separate document and use includetext to insert only the pages you want. -- Graham Mayor - Word MVP My web site www.gmayor.com Word MVP web site http://word.mvps.org Tico wrote: I am not sure if I understand you well. Do you mean to process for each kind of page separately (as I described in the method with sorting manually) and then to process the MailMerge again just to combine the pages into one file in a proper order? Regards Tico Użytkownik "Graham Mayor" napisał w wiadomości ... From your description you should conditionally insert the pages eg {IF {Mergefield Char} "\" "{IncludeText c:\\path\\page1.doc"}" ""} It is always easier not to add in the pages that you don't need than to remove them later -- Graham Mayor - Word MVP My web site www.gmayor.com Word MVP web site http://word.mvps.org Tico wrote: Sorry, I should have written 5 instead of 3 in my last news. I have 5 kinds of pages however from each record only from 1 to 3 pages can be necessary. In "my" method I "produce" all 5 pages for each Excel record and then I delete unnecessary pages using tha macro from you. Sorting the pages manually I had to repeat the process 5 times however in this case I was able to produce only necessary pages using SKIPIF, of course. But sorting it manually is really a nuisance. I thought about using the "NEXT RECORD IF ..." but in this case I'd have to be able to skip pages in Word. :-( Probably the best way would be to write a "regular" program in Visual Basic or so, but unfortuantely I am not able to. Regards Tico Użytkownik "Tico" napisał w wiadomości ... No because SKIPIF cause to skip a whole record. But I have to "produce" from 1 to 3 possible pages in Word from each record depending on the data in Excel file. That's why I have to "produce" all pages first and then to delete those which are not necessary. I tried to do it another way - I processed the Excel file 3 times and then I sorted the pages manually but in case of big files it is really a nuisance. The order of pages is important. I'll try to solve the problem continuing what I wrote in my prevoius news. I'll try not to center the first line however I don't understand why it worked when I processed it 3 times separately without the extra character. I don't know what causes the difference. Regards Tico Użytkownik "Graham Mayor" napisał w wiadomości ... I am totally bemused now. If you don't want the page(s) with this particular merge record, why are you merging the record in the first place? Wouldn't e.g. {SKIPIF {Mergefield Char} = "\"} work? -- Graham Mayor - Word MVP My web site www.gmayor.com Word MVP web site http://word.mvps.org Tico wrote: The same happens when I put in the Excel file "" instead of " " when I want a page not to be deleted. I think it is somehow connected with the sign of new page because sometimes it is OK but always after another sign of new page. However i don't know how to force a correct sign in the MaiMerge. Regards Tico Użytkownik "Tico" napisał w wiadomości ... I understand. I thought that everything was OK but I have one problem: the additional character damages to keeping a part of the first line in the center. I put in Excel file an addition column and the character "\" is put in it, if the page in Word should be deleted or the character " ", if the page in Word should'n be deleted. What is put : "\" or " " depends on other values in Excel file. Everything is OK but the first line on pages with " " is moved much more to the left than the 1 character (" ") should use (the same happens to pages with "\" but it is not important as they are deleted afterwards). The first line on each page consists of the constant text and a number that is put during the MailMerge process, like this ABCDEF GHIJ KLMNOP {MERGEFIELD No} The text should be in the center of the page, and the No on the right side. After I added the character it looks like this: {MERGEFIELD Char}ABCDEF GHIJ KLMNOP {MERGEFIELD No} (Before I put the additional character everything was OK and the constant text was in the center) My MailMerge "source" file consist of 5 pages, not just one. After the process of MailMerging I delete the "extra" pages using the macro from you. Each of the "source" 5 pages has similar first line as I described above. Could you help me once more, please? Regards Tico Użytkownik "Graham Mayor" napisał w wiadomości ... Page is a vague concept in Word which is not a page layout application and if you remove pages the document reflows to create a new 'page' structure. -- Graham Mayor - Word MVP My web site www.gmayor.com Word MVP web site http://word.mvps.org Tico wrote: Thank you both very, very much once again. I used the macro to the big MailMerge output file and it works perfectly. The macro would work faster if it could test just the first character on each page but I don't know how to change it. But it works very well and I am very grateful. As for a tutorial I expected something I had when I learnt other languages which began with "Hello World" or something like this. Then, step by step, it showed how to use more and more complicated language tools. Regards Tico Użytkownik "Graham Mayor" napisał w wiadomości ... If you are splitting the results of a mail merge, see http://www.gmayor.com/individual_merge_letters.htm As Doug says, the only way to learn vba is to put it to use to perform simple tasks and then get more adventurous. You can always use the macro recorder to give you some ideas. It is by no means perfect but it does help get you started. You will find lots of coding examples in the vba programming forums and on various web site, including my own. The vba help in Word 2007 is rather better than in earlier versions. -- Graham Mayor - Word MVP My web site www.gmayor.com Word MVP web site http://word.mvps.org Tico wrote: Thank you very, very much. I created a sample file and it works! Now I have to put the macro into my big file which is a result of MailMerge and make a lot of tests. By the way, I know almost nothing about VBA for Word. I looked at your page and I found a lot of interesting things there. However what I need most at the moment is any tutorial how to create simple macros in Word from the very beginning. Not just examples, which are important too, but first of all the most basic rules. I read that one of ways is to record macros using Word and then to analyse it in VBA Editor. I think that this can be useful later, when you know a lot, but not at the beginning. I am looking for any lessons, step by step showing what is neccessary in a macro and what it means. Then more and more functions to write working macros. Having such background I'll be able to learn using other methods. I tried to find anything like this in the Internet to download or use on line, but without any success. I found a lot for Excel but I read that the rules are not the same. Could you please advice me anything suitable for a person who is just starting with writing macros for Word? Thanks again for your help. Regards Tico Użytkownik "Graham Mayor" napisał w wiadomości ... The lines indicated in red have wrapped prematurely use the following which should not wrap Sub DeleteMarkedPages() Selection.HomeKey wdStory Selection.Find.ClearFormatting With Selection.Find Do While .Execute(findText:="\", _ MatchWildcards:=False, _ Wrap:=wdFindContinue, _ Forward:=True) = True Selection.Bookmarks("\page").Range.Delete Loop End With http://www.gmayor.com/installing_macro.htm The macro will remove any page with the \ character in Word 2007 and should work in Word 97 also, though I don't have it available to check. Word 2007 will open a Word document from Word 97 without the need to 'convert' it. -- Graham Mayor - Word MVP My web site www.gmayor.com Word MVP web site http://word.mvps.org Tico wrote: Thank you very much for your prompt reply. Unfortunately I don't know enough about macros to be able to use the macro. When I tried to use it I got the following lines in red: Do While .Execute(FindText:="#*#", MatchWildcards:=False, Wrap:=wdFindContinue, Forward:=True) = True Selection.Bookmarks("\page").Range.Delete regardless what I replaced the "#*#" with. My special character is \. I don't even know what I should writei n the macro: "#\#", "\" or simply \ I haven't found FindText in the "VBA for Dummies" for Office 97 that I have so I think I should save my file as Word 2007 first and then use the macro. I have Office 2007 (home edition) but I am not familiar with it yet, at least not to use macros. I am afraid I'll have to remove the pages manually. :-( Regards Tico Użytkownik "Doug Robbins - Word MVP" napisał w wiadomości ... Use a macro containing the following code where you replace the #*# with the special character that you intend to use. Selection.HomeKey wdStory Selection.Find.ClearFormatting With Selection.Find Do While .Execute(FindText:="#*#", MatchWildcards:=False, Wrap:=wdFindContinue, Forward:=True) = True Selection.Bookmarks("\page").Range.Delete Loop End With -- 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 "Tico" wrote in message ... Hi All, I have a big MS Word 97 file. I am looking for any method that let me remove automatically some pages which I can mark using, for example, a special character as the first on each page or in any other way. I would be also satisfied if I could automatically skip the pages whilst printing the file. I can use the MS Word 2007 to do it, if necessary. Could anyone help me please? The matter is urgent.:-) Regards Tico |
#21
Posted to microsoft.public.word.newusers
|
|||
|
|||
How to remove automatically some pages?
I read once again your below news and I think that I didn't understand well your advice:
"save each page as a separate document" when I tried to use it before. If I have to save each page as a separate document, I'll have to create thousands of files and for each file to include an information about Excel record (number?) in its name. I'm afraid this method would be more complicated and take more time than sorting manually. :-( Regards Tico Użytkownik "Graham Mayor" napisał w wiadomości ... You claim your merge requires a number of pages according to the data. Instead of merging all the pages and deleting the unwanted ones, include only the ones you need according to the requirements of the data ie save each page as a separate document and use includetext to insert only the pages you want. -- Graham Mayor - Word MVP My web site www.gmayor.com Word MVP web site http://word.mvps.org Tico wrote: I am not sure if I understand you well. Do you mean to process for each kind of page separately (as I described in the method with sorting manually) and then to process the MailMerge again just to combine the pages into one file in a proper order? Regards Tico Użytkownik "Graham Mayor" napisał w wiadomości ... From your description you should conditionally insert the pages eg {IF {Mergefield Char} "\" "{IncludeText c:\\path\\page1.doc"}" ""} It is always easier not to add in the pages that you don't need than to remove them later -- Graham Mayor - Word MVP My web site www.gmayor.com Word MVP web site http://word.mvps.org Tico wrote: Sorry, I should have written 5 instead of 3 in my last news. I have 5 kinds of pages however from each record only from 1 to 3 pages can be necessary. In "my" method I "produce" all 5 pages for each Excel record and then I delete unnecessary pages using tha macro from you. Sorting the pages manually I had to repeat the process 5 times however in this case I was able to produce only necessary pages using SKIPIF, of course. But sorting it manually is really a nuisance. I thought about using the "NEXT RECORD IF ..." but in this case I'd have to be able to skip pages in Word. :-( Probably the best way would be to write a "regular" program in Visual Basic or so, but unfortuantely I am not able to. Regards Tico Użytkownik "Tico" napisał w wiadomości ... No because SKIPIF cause to skip a whole record. But I have to "produce" from 1 to 3 possible pages in Word from each record depending on the data in Excel file. That's why I have to "produce" all pages first and then to delete those which are not necessary. I tried to do it another way - I processed the Excel file 3 times and then I sorted the pages manually but in case of big files it is really a nuisance. The order of pages is important. I'll try to solve the problem continuing what I wrote in my prevoius news. I'll try not to center the first line however I don't understand why it worked when I processed it 3 times separately without the extra character. I don't know what causes the difference. Regards Tico Użytkownik "Graham Mayor" napisał w wiadomości ... I am totally bemused now. If you don't want the page(s) with this particular merge record, why are you merging the record in the first place? Wouldn't e.g. {SKIPIF {Mergefield Char} = "\"} work? -- Graham Mayor - Word MVP My web site www.gmayor.com Word MVP web site http://word.mvps.org Tico wrote: The same happens when I put in the Excel file "" instead of " " when I want a page not to be deleted. I think it is somehow connected with the sign of new page because sometimes it is OK but always after another sign of new page. However i don't know how to force a correct sign in the MaiMerge. Regards Tico Użytkownik "Tico" napisał w wiadomości ... I understand. I thought that everything was OK but I have one problem: the additional character damages to keeping a part of the first line in the center. I put in Excel file an addition column and the character "\" is put in it, if the page in Word should be deleted or the character " ", if the page in Word should'n be deleted. What is put : "\" or " " depends on other values in Excel file. Everything is OK but the first line on pages with " " is moved much more to the left than the 1 character (" ") should use (the same happens to pages with "\" but it is not important as they are deleted afterwards). The first line on each page consists of the constant text and a number that is put during the MailMerge process, like this ABCDEF GHIJ KLMNOP {MERGEFIELD No} The text should be in the center of the page, and the No on the right side. After I added the character it looks like this: {MERGEFIELD Char}ABCDEF GHIJ KLMNOP {MERGEFIELD No} (Before I put the additional character everything was OK and the constant text was in the center) My MailMerge "source" file consist of 5 pages, not just one. After the process of MailMerging I delete the "extra" pages using the macro from you. Each of the "source" 5 pages has similar first line as I described above. Could you help me once more, please? Regards Tico Użytkownik "Graham Mayor" napisał w wiadomości ... Page is a vague concept in Word which is not a page layout application and if you remove pages the document reflows to create a new 'page' structure. -- Graham Mayor - Word MVP My web site www.gmayor.com Word MVP web site http://word.mvps.org Tico wrote: Thank you both very, very much once again. I used the macro to the big MailMerge output file and it works perfectly. The macro would work faster if it could test just the first character on each page but I don't know how to change it. But it works very well and I am very grateful. As for a tutorial I expected something I had when I learnt other languages which began with "Hello World" or something like this. Then, step by step, it showed how to use more and more complicated language tools. Regards Tico Użytkownik "Graham Mayor" napisał w wiadomości ... If you are splitting the results of a mail merge, see http://www.gmayor.com/individual_merge_letters.htm As Doug says, the only way to learn vba is to put it to use to perform simple tasks and then get more adventurous. You can always use the macro recorder to give you some ideas. It is by no means perfect but it does help get you started. You will find lots of coding examples in the vba programming forums and on various web site, including my own. The vba help in Word 2007 is rather better than in earlier versions. -- Graham Mayor - Word MVP My web site www.gmayor.com Word MVP web site http://word.mvps.org Tico wrote: Thank you very, very much. I created a sample file and it works! Now I have to put the macro into my big file which is a result of MailMerge and make a lot of tests. By the way, I know almost nothing about VBA for Word. I looked at your page and I found a lot of interesting things there. However what I need most at the moment is any tutorial how to create simple macros in Word from the very beginning. Not just examples, which are important too, but first of all the most basic rules. I read that one of ways is to record macros using Word and then to analyse it in VBA Editor. I think that this can be useful later, when you know a lot, but not at the beginning. I am looking for any lessons, step by step showing what is neccessary in a macro and what it means. Then more and more functions to write working macros. Having such background I'll be able to learn using other methods. I tried to find anything like this in the Internet to download or use on line, but without any success. I found a lot for Excel but I read that the rules are not the same. Could you please advice me anything suitable for a person who is just starting with writing macros for Word? Thanks again for your help. Regards Tico Użytkownik "Graham Mayor" napisał w wiadomości ... The lines indicated in red have wrapped prematurely use the following which should not wrap Sub DeleteMarkedPages() Selection.HomeKey wdStory Selection.Find.ClearFormatting With Selection.Find Do While .Execute(findText:="\", _ MatchWildcards:=False, _ Wrap:=wdFindContinue, _ Forward:=True) = True Selection.Bookmarks("\page").Range.Delete Loop End With http://www.gmayor.com/installing_macro.htm The macro will remove any page with the \ character in Word 2007 and should work in Word 97 also, though I don't have it available to check. Word 2007 will open a Word document from Word 97 without the need to 'convert' it. -- Graham Mayor - Word MVP My web site www.gmayor.com Word MVP web site http://word.mvps.org Tico wrote: Thank you very much for your prompt reply. Unfortunately I don't know enough about macros to be able to use the macro. When I tried to use it I got the following lines in red: Do While .Execute(FindText:="#*#", MatchWildcards:=False, Wrap:=wdFindContinue, Forward:=True) = True Selection.Bookmarks("\page").Range.Delete regardless what I replaced the "#*#" with. My special character is \. I don't even know what I should writei n the macro: "#\#", "\" or simply \ I haven't found FindText in the "VBA for Dummies" for Office 97 that I have so I think I should save my file as Word 2007 first and then use the macro. I have Office 2007 (home edition) but I am not familiar with it yet, at least not to use macros. I am afraid I'll have to remove the pages manually. :-( Regards Tico Użytkownik "Doug Robbins - Word MVP" napisał w wiadomości ... Use a macro containing the following code where you replace the #*# with the special character that you intend to use. Selection.HomeKey wdStory Selection.Find.ClearFormatting With Selection.Find Do While .Execute(FindText:="#*#", MatchWildcards:=False, Wrap:=wdFindContinue, Forward:=True) = True Selection.Bookmarks("\page").Range.Delete Loop End With -- 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 "Tico" wrote in message ... Hi All, I have a big MS Word 97 file. I am looking for any method that let me remove automatically some pages which I can mark using, for example, a special character as the first on each page or in any other way. I would be also satisfied if I could automatically skip the pages whilst printing the file. I can use the MS Word 2007 to do it, if necessary. Could anyone help me please? The matter is urgent.:-) Regards Tico |
#22
Posted to microsoft.public.word.newusers
|
|||
|
|||
How to remove automatically some pages?
We seem to be talking at cross purposes. From what you have posted earlier,
your merge document has five pages (not thousands), some of which will not be required according to the dictates of the data. You have said that you have a field in the data source which indicates which page will not be required for a given record. Save each of the five pages as a separate document and note the filename and path. Then your merge document will contain the conditional fields on the same line eg {IF {Mergefield Indicatorfieldname} "\" "{Includetext "c:\\path\\page1.doc" ""}{IF {Mergefield Indicatorfieldname} "\" "{Includetext "c:\\path\\page2.doc" ""}{IF {Mergefield Indicatorfieldname} "\" "{Includetext "c:\\path\\page2.doc" ""}etc These are fields not simply typed in at the keyboard. Use CTRL+F9 for the brackets, and note that the paths must use double slashes and of course they and the fieldnames must match the actual filenames and fieldnames. Unless the first page of your merge document runs top more than one page, there will only be one page in the merge document - unless the conditions require that the includetext fields include them. When you then merge your database, you will have only the required number of pages for each record. The merge fields in the inserted documents will work as if they were typed on the page. -- Graham Mayor - Word MVP My web site www.gmayor.com Word MVP web site http://word.mvps.org Tico wrote: I read once again your below news and I think that I didn't understand well your advice: "save each page as a separate document" when I tried to use it before. If I have to save each page as a separate document, I'll have to create thousands of files and for each file to include an information about Excel record (number?) in its name. I'm afraid this method would be more complicated and take more time than sorting manually. :-( Regards Tico Użytkownik "Graham Mayor" napisał w wiadomości ... You claim your merge requires a number of pages according to the data. Instead of merging all the pages and deleting the unwanted ones, include only the ones you need according to the requirements of the data ie save each page as a separate document and use includetext to insert only the pages you want. -- Graham Mayor - Word MVP My web site www.gmayor.com Word MVP web site http://word.mvps.org Tico wrote: I am not sure if I understand you well. Do you mean to process for each kind of page separately (as I described in the method with sorting manually) and then to process the MailMerge again just to combine the pages into one file in a proper order? Regards Tico Użytkownik "Graham Mayor" napisał w wiadomości ... From your description you should conditionally insert the pages eg {IF {Mergefield Char} "\" "{IncludeText c:\\path\\page1.doc"}" ""} It is always easier not to add in the pages that you don't need than to remove them later -- Graham Mayor - Word MVP My web site www.gmayor.com Word MVP web site http://word.mvps.org Tico wrote: Sorry, I should have written 5 instead of 3 in my last news. I have 5 kinds of pages however from each record only from 1 to 3 pages can be necessary. In "my" method I "produce" all 5 pages for each Excel record and then I delete unnecessary pages using tha macro from you. Sorting the pages manually I had to repeat the process 5 times however in this case I was able to produce only necessary pages using SKIPIF, of course. But sorting it manually is really a nuisance. I thought about using the "NEXT RECORD IF ..." but in this case I'd have to be able to skip pages in Word. :-( Probably the best way would be to write a "regular" program in Visual Basic or so, but unfortuantely I am not able to. Regards Tico Użytkownik "Tico" napisał w wiadomości ... No because SKIPIF cause to skip a whole record. But I have to "produce" from 1 to 3 possible pages in Word from each record depending on the data in Excel file. That's why I have to "produce" all pages first and then to delete those which are not necessary. I tried to do it another way - I processed the Excel file 3 times and then I sorted the pages manually but in case of big files it is really a nuisance. The order of pages is important. I'll try to solve the problem continuing what I wrote in my prevoius news. I'll try not to center the first line however I don't understand why it worked when I processed it 3 times separately without the extra character. I don't know what causes the difference. Regards Tico Użytkownik "Graham Mayor" napisał w wiadomości ... I am totally bemused now. If you don't want the page(s) with this particular merge record, why are you merging the record in the first place? Wouldn't e.g. {SKIPIF {Mergefield Char} = "\"} work? -- Graham Mayor - Word MVP My web site www.gmayor.com Word MVP web site http://word.mvps.org Tico wrote: The same happens when I put in the Excel file "" instead of " " when I want a page not to be deleted. I think it is somehow connected with the sign of new page because sometimes it is OK but always after another sign of new page. However i don't know how to force a correct sign in the MaiMerge. Regards Tico Użytkownik "Tico" napisał w wiadomości ... I understand. I thought that everything was OK but I have one problem: the additional character damages to keeping a part of the first line in the center. I put in Excel file an addition column and the character "\" is put in it, if the page in Word should be deleted or the character " ", if the page in Word should'n be deleted. What is put : "\" or " " depends on other values in Excel file. Everything is OK but the first line on pages with " " is moved much more to the left than the 1 character (" ") should use (the same happens to pages with "\" but it is not important as they are deleted afterwards). The first line on each page consists of the constant text and a number that is put during the MailMerge process, like this ABCDEF GHIJ KLMNOP {MERGEFIELD No} The text should be in the center of the page, and the No on the right side. After I added the character it looks like this: {MERGEFIELD Char}ABCDEF GHIJ KLMNOP {MERGEFIELD No} (Before I put the additional character everything was OK and the constant text was in the center) My MailMerge "source" file consist of 5 pages, not just one. After the process of MailMerging I delete the "extra" pages using the macro from you. Each of the "source" 5 pages has similar first line as I described above. Could you help me once more, please? Regards Tico Użytkownik "Graham Mayor" napisał w wiadomości ... Page is a vague concept in Word which is not a page layout application and if you remove pages the document reflows to create a new 'page' structure. -- Graham Mayor - Word MVP My web site www.gmayor.com Word MVP web site http://word.mvps.org Tico wrote: Thank you both very, very much once again. I used the macro to the big MailMerge output file and it works perfectly. The macro would work faster if it could test just the first character on each page but I don't know how to change it. But it works very well and I am very grateful. As for a tutorial I expected something I had when I learnt other languages which began with "Hello World" or something like this. Then, step by step, it showed how to use more and more complicated language tools. Regards Tico Użytkownik "Graham Mayor" napisał w wiadomości ... If you are splitting the results of a mail merge, see http://www.gmayor.com/individual_merge_letters.htm As Doug says, the only way to learn vba is to put it to use to perform simple tasks and then get more adventurous. You can always use the macro recorder to give you some ideas. It is by no means perfect but it does help get you started. You will find lots of coding examples in the vba programming forums and on various web site, including my own. The vba help in Word 2007 is rather better than in earlier versions. -- Graham Mayor - Word MVP My web site www.gmayor.com Word MVP web site http://word.mvps.org Tico wrote: Thank you very, very much. I created a sample file and it works! Now I have to put the macro into my big file which is a result of MailMerge and make a lot of tests. By the way, I know almost nothing about VBA for Word. I looked at your page and I found a lot of interesting things there. However what I need most at the moment is any tutorial how to create simple macros in Word from the very beginning. Not just examples, which are important too, but first of all the most basic rules. I read that one of ways is to record macros using Word and then to analyse it in VBA Editor. I think that this can be useful later, when you know a lot, but not at the beginning. I am looking for any lessons, step by step showing what is neccessary in a macro and what it means. Then more and more functions to write working macros. Having such background I'll be able to learn using other methods. I tried to find anything like this in the Internet to download or use on line, but without any success. I found a lot for Excel but I read that the rules are not the same. Could you please advice me anything suitable for a person who is just starting with writing macros for Word? Thanks again for your help. Regards Tico Użytkownik "Graham Mayor" napisał w wiadomości ... The lines indicated in red have wrapped prematurely use the following which should not wrap Sub DeleteMarkedPages() Selection.HomeKey wdStory Selection.Find.ClearFormatting With Selection.Find Do While .Execute(findText:="\", _ MatchWildcards:=False, _ Wrap:=wdFindContinue, _ Forward:=True) = True Selection.Bookmarks("\page").Range.Delete Loop End With http://www.gmayor.com/installing_macro.htm The macro will remove any page with the \ character in Word 2007 and should work in Word 97 also, though I don't have it available to check. Word 2007 will open a Word document from Word 97 without the need to 'convert' it. -- Graham Mayor - Word MVP My web site www.gmayor.com Word MVP web site http://word.mvps.org Tico wrote: Thank you very much for your prompt reply. Unfortunately I don't know enough about macros to be able to use the macro. When I tried to use it I got the following lines in red: Do While .Execute(FindText:="#*#", MatchWildcards:=False, Wrap:=wdFindContinue, Forward:=True) = True Selection.Bookmarks("\page").Range.Delete regardless what I replaced the "#*#" with. My special character is \. I don't even know what I should writei n the macro: "#\#", "\" or simply \ I haven't found FindText in the "VBA for Dummies" for Office 97 that I have so I think I should save my file as Word 2007 first and then use the macro. I have Office 2007 (home edition) but I am not familiar with it yet, at least not to use macros. I am afraid I'll have to remove the pages manually. :-( Regards Tico Użytkownik "Doug Robbins - Word MVP" napisał w wiadomości ... Use a macro containing the following code where you replace the #*# with the special character that you intend to use. Selection.HomeKey wdStory Selection.Find.ClearFormatting With Selection.Find Do While .Execute(FindText:="#*#", MatchWildcards:=False, Wrap:=wdFindContinue, Forward:=True) = True Selection.Bookmarks("\page").Range.Delete Loop End With -- 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 "Tico" wrote in message ... Hi All, I have a big MS Word 97 file. I am looking for any method that let me remove automatically some pages which I can mark using, for example, a special character as the first on each page or in any other way. I would be also satisfied if I could automatically skip the pages whilst printing the file. I can use the MS Word 2007 to do it, if necessary. Could anyone help me please? The matter is urgent.:-) Regards Tico |
#23
Posted to microsoft.public.word.newusers
|
|||
|
|||
How to remove automatically some pages?
Thanks a lot once more.
We seem to be talking at cross purposes I am very sorry that my English is so poor. Another problem is that I cannot use English versions of Windows and MS Office so when I want to describe anything I have to translate it into English. From what you have posted earlier, your merge document has five pages (not thousands), some of which will not be required according to the dictates of the data. Right. I'll have thousands of pages as a result of Mailmerge because the Excel file contains thousends (or at least hundreds) of records. You have said that you have a field in the data source which indicates which page will not be required for a given record. Right. Save each of the five pages as a separate document and note the filename and path. Done. Each page contains a table. Besides, fieldnames are rather long so each "source" takes more than 1 page in fact. If it is necessary I could shorten the names of the fields (=names of Excel columns) {IF {Mergefield Indicatorfieldname} "\" "{Includetext "c:\\path\\page1.doc" ""}{IF {Mergefield Indicatorfieldname} "\" "{Includetext "c:\\path\\page2.doc" ""}{IF {Mergefield Indicatorfieldname} "\" "{Includetext "c:\\path\\page2.doc" ""}etc I opened a new Word97 file and then use: Tools MailMerge 1. Create Form Letters Active Window 2. Get Data Open Data Source I opened my Excel file. Then I clicked on the Edit Main Document button. I typed what you wrote using CTRL+F9 (I forgot about it when I tried before). To get Mergefileld Indicatorfieldname I selected it from the Insert Merge Field (left up corner) The paths use double slashes and the names of the files are correct. Afterwards I use: Tools MailMerge 3. Merge button The following options were selected: Merge to a New Document Records to be saved All Without printing empty records Then I clicked on Merge I got the following warning: Microsoft Word You cannot insert the fields DATA, NEXT, NEXTIF or SKIPIF inside other fields (this is my translation) and after clicking on OK I got the following information: MailMerge An error was encountered when counting a value of field in record 1 (this is also my tranaslation) After clicking OK I got just 1 empty page (without inserted values) - the first from 5 pages. Unless the first page of your merge document runs top more than one page, there will only be one page in the merge document - unless the conditions require that the includetext fields include them. I am very sorry but I don't understand it. I suppose it is about what I got but I have language problems with understanding it. Could you please write it more simple, without using the word "unless" which is very difficult to me when I have to understand anything precisely. Sorry. Best regards Tico Użytkownik "Graham Mayor" napisał w wiadomości ... We seem to be talking at cross purposes. From what you have posted earlier, your merge document has five pages (not thousands), some of which will not be required according to the dictates of the data. You have said that you have a field in the data source which indicates which page will not be required for a given record. Save each of the five pages as a separate document and note the filename and path. Then your merge document will contain the conditional fields on the same line eg {IF {Mergefield Indicatorfieldname} "\" "{Includetext "c:\\path\\page1.doc" ""}{IF {Mergefield Indicatorfieldname} "\" "{Includetext "c:\\path\\page2.doc" ""}{IF {Mergefield Indicatorfieldname} "\" "{Includetext "c:\\path\\page2.doc" ""}etc These are fields not simply typed in at the keyboard. Use CTRL+F9 for the brackets, and note that the paths must use double slashes and of course they and the fieldnames must match the actual filenames and fieldnames. Unless the first page of your merge document runs top more than one page, there will only be one page in the merge document - unless the conditions require that the includetext fields include them. When you then merge your database, you will have only the required number of pages for each record. The merge fields in the inserted documents will work as if they were typed on the page. -- Graham Mayor - Word MVP My web site www.gmayor.com Word MVP web site http://word.mvps.org Tico wrote: I read once again your below news and I think that I didn't understand well your advice: "save each page as a separate document" when I tried to use it before. If I have to save each page as a separate document, I'll have to create thousands of files and for each file to include an information about Excel record (number?) in its name. I'm afraid this method would be more complicated and take more time than sorting manually. :-( Regards Tico Użytkownik "Graham Mayor" napisał w wiadomości ... You claim your merge requires a number of pages according to the data. Instead of merging all the pages and deleting the unwanted ones, include only the ones you need according to the requirements of the data ie save each page as a separate document and use includetext to insert only the pages you want. -- Graham Mayor - Word MVP My web site www.gmayor.com Word MVP web site http://word.mvps.org Tico wrote: I am not sure if I understand you well. Do you mean to process for each kind of page separately (as I described in the method with sorting manually) and then to process the MailMerge again just to combine the pages into one file in a proper order? Regards Tico Użytkownik "Graham Mayor" napisał w wiadomości ... From your description you should conditionally insert the pages eg {IF {Mergefield Char} "\" "{IncludeText c:\\path\\page1.doc"}" ""} It is always easier not to add in the pages that you don't need than to remove them later -- Graham Mayor - Word MVP My web site www.gmayor.com Word MVP web site http://word.mvps.org Tico wrote: Sorry, I should have written 5 instead of 3 in my last news. I have 5 kinds of pages however from each record only from 1 to 3 pages can be necessary. In "my" method I "produce" all 5 pages for each Excel record and then I delete unnecessary pages using tha macro from you. Sorting the pages manually I had to repeat the process 5 times however in this case I was able to produce only necessary pages using SKIPIF, of course. But sorting it manually is really a nuisance. I thought about using the "NEXT RECORD IF ..." but in this case I'd have to be able to skip pages in Word. :-( Probably the best way would be to write a "regular" program in Visual Basic or so, but unfortuantely I am not able to. Regards Tico Użytkownik "Tico" napisał w wiadomości ... No because SKIPIF cause to skip a whole record. But I have to "produce" from 1 to 3 possible pages in Word from each record depending on the data in Excel file. That's why I have to "produce" all pages first and then to delete those which are not necessary. I tried to do it another way - I processed the Excel file 3 times and then I sorted the pages manually but in case of big files it is really a nuisance. The order of pages is important. I'll try to solve the problem continuing what I wrote in my prevoius news. I'll try not to center the first line however I don't understand why it worked when I processed it 3 times separately without the extra character. I don't know what causes the difference. Regards Tico Użytkownik "Graham Mayor" napisał w wiadomości ... I am totally bemused now. If you don't want the page(s) with this particular merge record, why are you merging the record in the first place? Wouldn't e.g. {SKIPIF {Mergefield Char} = "\"} work? -- Graham Mayor - Word MVP My web site www.gmayor.com Word MVP web site http://word.mvps.org Tico wrote: The same happens when I put in the Excel file "" instead of " " when I want a page not to be deleted. I think it is somehow connected with the sign of new page because sometimes it is OK but always after another sign of new page. However i don't know how to force a correct sign in the MaiMerge. Regards Tico Użytkownik "Tico" napisał w wiadomości ... I understand. I thought that everything was OK but I have one problem: the additional character damages to keeping a part of the first line in the center. I put in Excel file an addition column and the character "\" is put in it, if the page in Word should be deleted or the character " ", if the page in Word should'n be deleted. What is put : "\" or " " depends on other values in Excel file. Everything is OK but the first line on pages with " " is moved much more to the left than the 1 character (" ") should use (the same happens to pages with "\" but it is not important as they are deleted afterwards). The first line on each page consists of the constant text and a number that is put during the MailMerge process, like this ABCDEF GHIJ KLMNOP {MERGEFIELD No} The text should be in the center of the page, and the No on the right side. After I added the character it looks like this: {MERGEFIELD Char}ABCDEF GHIJ KLMNOP {MERGEFIELD No} (Before I put the additional character everything was OK and the constant text was in the center) My MailMerge "source" file consist of 5 pages, not just one. After the process of MailMerging I delete the "extra" pages using the macro from you. Each of the "source" 5 pages has similar first line as I described above. Could you help me once more, please? Regards Tico Użytkownik "Graham Mayor" napisał w wiadomości ... Page is a vague concept in Word which is not a page layout application and if you remove pages the document reflows to create a new 'page' structure. -- Graham Mayor - Word MVP My web site www.gmayor.com Word MVP web site http://word.mvps.org Tico wrote: Thank you both very, very much once again. I used the macro to the big MailMerge output file and it works perfectly. The macro would work faster if it could test just the first character on each page but I don't know how to change it. But it works very well and I am very grateful. As for a tutorial I expected something I had when I learnt other languages which began with "Hello World" or something like this. Then, step by step, it showed how to use more and more complicated language tools. Regards Tico Użytkownik "Graham Mayor" napisał w wiadomości ... If you are splitting the results of a mail merge, see http://www.gmayor.com/individual_merge_letters.htm As Doug says, the only way to learn vba is to put it to use to perform simple tasks and then get more adventurous. You can always use the macro recorder to give you some ideas. It is by no means perfect but it does help get you started. You will find lots of coding examples in the vba programming forums and on various web site, including my own. The vba help in Word 2007 is rather better than in earlier versions. -- Graham Mayor - Word MVP My web site www.gmayor.com Word MVP web site http://word.mvps.org Tico wrote: Thank you very, very much. I created a sample file and it works! Now I have to put the macro into my big file which is a result of MailMerge and make a lot of tests. By the way, I know almost nothing about VBA for Word. I looked at your page and I found a lot of interesting things there. However what I need most at the moment is any tutorial how to create simple macros in Word from the very beginning. Not just examples, which are important too, but first of all the most basic rules. I read that one of ways is to record macros using Word and then to analyse it in VBA Editor. I think that this can be useful later, when you know a lot, but not at the beginning. I am looking for any lessons, step by step showing what is neccessary in a macro and what it means. Then more and more functions to write working macros. Having such background I'll be able to learn using other methods. I tried to find anything like this in the Internet to download or use on line, but without any success. I found a lot for Excel but I read that the rules are not the same. Could you please advice me anything suitable for a person who is just starting with writing macros for Word? Thanks again for your help. Regards Tico Użytkownik "Graham Mayor" napisał w wiadomości ... The lines indicated in red have wrapped prematurely use the following which should not wrap Sub DeleteMarkedPages() Selection.HomeKey wdStory Selection.Find.ClearFormatting With Selection.Find Do While .Execute(findText:="\", _ MatchWildcards:=False, _ Wrap:=wdFindContinue, _ Forward:=True) = True Selection.Bookmarks("\page").Range.Delete Loop End With http://www.gmayor.com/installing_macro.htm The macro will remove any page with the \ character in Word 2007 and should work in Word 97 also, though I don't have it available to check. Word 2007 will open a Word document from Word 97 without the need to 'convert' it. -- Graham Mayor - Word MVP My web site www.gmayor.com Word MVP web site http://word.mvps.org Tico wrote: Thank you very much for your prompt reply. Unfortunately I don't know enough about macros to be able to use the macro. When I tried to use it I got the following lines in red: Do While .Execute(FindText:="#*#", MatchWildcards:=False, Wrap:=wdFindContinue, Forward:=True) = True Selection.Bookmarks("\page").Range.Delete regardless what I replaced the "#*#" with. My special character is \. I don't even know what I should writei n the macro: "#\#", "\" or simply \ I haven't found FindText in the "VBA for Dummies" for Office 97 that I have so I think I should save my file as Word 2007 first and then use the macro. I have Office 2007 (home edition) but I am not familiar with it yet, at least not to use macros. I am afraid I'll have to remove the pages manually. :-( Regards Tico Użytkownik "Doug Robbins - Word MVP" napisał w wiadomości ... Use a macro containing the following code where you replace the #*# with the special character that you intend to use. Selection.HomeKey wdStory Selection.Find.ClearFormatting With Selection.Find Do While .Execute(FindText:="#*#", MatchWildcards:=False, Wrap:=wdFindContinue, Forward:=True) = True Selection.Bookmarks("\page").Range.Delete Loop End With -- 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 "Tico" wrote in message ... Hi All, I have a big MS Word 97 file. I am looking for any method that let me remove automatically some pages which I can mark using, for example, a special character as the first on each page or in any other way. I would be also satisfied if I could automatically skip the pages whilst printing the file. I can use the MS Word 2007 to do it, if necessary. Could anyone help me please? The matter is urgent.:-) Regards Tico |
#24
Posted to microsoft.public.word.newusers
|
|||
|
|||
How to remove automatically some pages?
This is complicated enough to explain in English
Given that the language problem might then be reversed, I wonder if it would help if you sent me the merge documents so that I can see what you are doing? Zip up the five(?) documents and mail them to the link on my web site. I *may* be able to spot the problem. If you are unable to do that - e-mail me a contact address and I'll send you a sample working document and you can see how it is supposed to work. -- Graham Mayor - Word MVP My web site www.gmayor.com Word MVP web site http://word.mvps.org Tico wrote: Thanks a lot once more. We seem to be talking at cross purposes I am very sorry that my English is so poor. Another problem is that I cannot use English versions of Windows and MS Office so when I want to describe anything I have to translate it into English. From what you have posted earlier, your merge document has five pages (not thousands), some of which will not be required according to the dictates of the data. Right. I'll have thousands of pages as a result of Mailmerge because the Excel file contains thousends (or at least hundreds) of records. You have said that you have a field in the data source which indicates which page will not be required for a given record. Right. Save each of the five pages as a separate document and note the filename and path. Done. Each page contains a table. Besides, fieldnames are rather long so each "source" takes more than 1 page in fact. If it is necessary I could shorten the names of the fields (=names of Excel columns) {IF {Mergefield Indicatorfieldname} "\" "{Includetext "c:\\path\\page1.doc" ""}{IF {Mergefield Indicatorfieldname} "\" "{Includetext "c:\\path\\page2.doc" ""}{IF {Mergefield Indicatorfieldname} "\" "{Includetext "c:\\path\\page2.doc" ""}etc I opened a new Word97 file and then use: Tools MailMerge 1. Create Form Letters Active Window 2. Get Data Open Data Source I opened my Excel file. Then I clicked on the Edit Main Document button. I typed what you wrote using CTRL+F9 (I forgot about it when I tried before). To get Mergefileld Indicatorfieldname I selected it from the Insert Merge Field (left up corner) The paths use double slashes and the names of the files are correct. Afterwards I use: Tools MailMerge 3. Merge button The following options were selected: Merge to a New Document Records to be saved All Without printing empty records Then I clicked on Merge I got the following warning: Microsoft Word You cannot insert the fields DATA, NEXT, NEXTIF or SKIPIF inside other fields (this is my translation) and after clicking on OK I got the following information: MailMerge An error was encountered when counting a value of field in record 1 (this is also my tranaslation) After clicking OK I got just 1 empty page (without inserted values) - the first from 5 pages. Unless the first page of your merge document runs top more than one page, there will only be one page in the merge document - unless the conditions require that the includetext fields include them. I am very sorry but I don't understand it. I suppose it is about what I got but I have language problems with understanding it. Could you please write it more simple, without using the word "unless" which is very difficult to me when I have to understand anything precisely. Sorry. Best regards Tico Użytkownik "Graham Mayor" napisał w wiadomości ... We seem to be talking at cross purposes. From what you have posted earlier, your merge document has five pages (not thousands), some of which will not be required according to the dictates of the data. You have said that you have a field in the data source which indicates which page will not be required for a given record. Save each of the five pages as a separate document and note the filename and path. Then your merge document will contain the conditional fields on the same line eg {IF {Mergefield Indicatorfieldname} "\" "{Includetext "c:\\path\\page1.doc" ""}{IF {Mergefield Indicatorfieldname} "\" "{Includetext "c:\\path\\page2.doc" ""}{IF {Mergefield Indicatorfieldname} "\" "{Includetext "c:\\path\\page2.doc" ""}etc These are fields not simply typed in at the keyboard. Use CTRL+F9 for the brackets, and note that the paths must use double slashes and of course they and the fieldnames must match the actual filenames and fieldnames. Unless the first page of your merge document runs top more than one page, there will only be one page in the merge document - unless the conditions require that the includetext fields include them. When you then merge your database, you will have only the required number of pages for each record. The merge fields in the inserted documents will work as if they were typed on the page. -- Graham Mayor - Word MVP My web site www.gmayor.com Word MVP web site http://word.mvps.org Tico wrote: I read once again your below news and I think that I didn't understand well your advice: "save each page as a separate document" when I tried to use it before. If I have to save each page as a separate document, I'll have to create thousands of files and for each file to include an information about Excel record (number?) in its name. I'm afraid this method would be more complicated and take more time than sorting manually. :-( Regards Tico Użytkownik "Graham Mayor" napisał w wiadomości ... You claim your merge requires a number of pages according to the data. Instead of merging all the pages and deleting the unwanted ones, include only the ones you need according to the requirements of the data ie save each page as a separate document and use includetext to insert only the pages you want. -- Graham Mayor - Word MVP My web site www.gmayor.com Word MVP web site http://word.mvps.org Tico wrote: I am not sure if I understand you well. Do you mean to process for each kind of page separately (as I described in the method with sorting manually) and then to process the MailMerge again just to combine the pages into one file in a proper order? Regards Tico Użytkownik "Graham Mayor" napisał w wiadomości ... From your description you should conditionally insert the pages eg {IF {Mergefield Char} "\" "{IncludeText c:\\path\\page1.doc"}" ""} It is always easier not to add in the pages that you don't need than to remove them later -- Graham Mayor - Word MVP My web site www.gmayor.com Word MVP web site http://word.mvps.org Tico wrote: Sorry, I should have written 5 instead of 3 in my last news. I have 5 kinds of pages however from each record only from 1 to 3 pages can be necessary. In "my" method I "produce" all 5 pages for each Excel record and then I delete unnecessary pages using tha macro from you. Sorting the pages manually I had to repeat the process 5 times however in this case I was able to produce only necessary pages using SKIPIF, of course. But sorting it manually is really a nuisance. I thought about using the "NEXT RECORD IF ..." but in this case I'd have to be able to skip pages in Word. :-( Probably the best way would be to write a "regular" program in Visual Basic or so, but unfortuantely I am not able to. Regards Tico Użytkownik "Tico" napisał w wiadomości ... No because SKIPIF cause to skip a whole record. But I have to "produce" from 1 to 3 possible pages in Word from each record depending on the data in Excel file. That's why I have to "produce" all pages first and then to delete those which are not necessary. I tried to do it another way - I processed the Excel file 3 times and then I sorted the pages manually but in case of big files it is really a nuisance. The order of pages is important. I'll try to solve the problem continuing what I wrote in my prevoius news. I'll try not to center the first line however I don't understand why it worked when I processed it 3 times separately without the extra character. I don't know what causes the difference. Regards Tico Użytkownik "Graham Mayor" napisał w wiadomości ... I am totally bemused now. If you don't want the page(s) with this particular merge record, why are you merging the record in the first place? Wouldn't e.g. {SKIPIF {Mergefield Char} = "\"} work? -- Graham Mayor - Word MVP My web site www.gmayor.com Word MVP web site http://word.mvps.org Tico wrote: The same happens when I put in the Excel file "" instead of " " when I want a page not to be deleted. I think it is somehow connected with the sign of new page because sometimes it is OK but always after another sign of new page. However i don't know how to force a correct sign in the MaiMerge. Regards Tico Użytkownik "Tico" napisał w wiadomości ... I understand. I thought that everything was OK but I have one problem: the additional character damages to keeping a part of the first line in the center. I put in Excel file an addition column and the character "\" is put in it, if the page in Word should be deleted or the character " ", if the page in Word should'n be deleted. What is put : "\" or " " depends on other values in Excel file. Everything is OK but the first line on pages with " " is moved much more to the left than the 1 character (" ") should use (the same happens to pages with "\" but it is not important as they are deleted afterwards). The first line on each page consists of the constant text and a number that is put during the MailMerge process, like this ABCDEF GHIJ KLMNOP {MERGEFIELD No} The text should be in the center of the page, and the No on the right side. After I added the character it looks like this: {MERGEFIELD Char}ABCDEF GHIJ KLMNOP {MERGEFIELD No} (Before I put the additional character everything was OK and the constant text was in the center) My MailMerge "source" file consist of 5 pages, not just one. After the process of MailMerging I delete the "extra" pages using the macro from you. Each of the "source" 5 pages has similar first line as I described above. Could you help me once more, please? Regards Tico Użytkownik "Graham Mayor" napisał w wiadomości ... Page is a vague concept in Word which is not a page layout application and if you remove pages the document reflows to create a new 'page' structure. -- Graham Mayor - Word MVP My web site www.gmayor.com Word MVP web site http://word.mvps.org Tico wrote: Thank you both very, very much once again. I used the macro to the big MailMerge output file and it works perfectly. The macro would work faster if it could test just the first character on each page but I don't know how to change it. But it works very well and I am very grateful. As for a tutorial I expected something I had when I learnt other languages which began with "Hello World" or something like this. Then, step by step, it showed how to use more and more complicated language tools. Regards Tico Użytkownik "Graham Mayor" napisał w wiadomości ... If you are splitting the results of a mail merge, see http://www.gmayor.com/individual_merge_letters.htm As Doug says, the only way to learn vba is to put it to use to perform simple tasks and then get more adventurous. You can always use the macro recorder to give you some ideas. It is by no means perfect but it does help get you started. You will find lots of coding examples in the vba programming forums and on various web site, including my own. The vba help in Word 2007 is rather better than in earlier versions. -- Graham Mayor - Word MVP My web site www.gmayor.com Word MVP web site http://word.mvps.org Tico wrote: Thank you very, very much. I created a sample file and it works! Now I have to put the macro into my big file which is a result of MailMerge and make a lot of tests. By the way, I know almost nothing about VBA for Word. I looked at your page and I found a lot of interesting things there. However what I need most at the moment is any tutorial how to create simple macros in Word from the very beginning. Not just examples, which are important too, but first of all the most basic rules. I read that one of ways is to record macros using Word and then to analyse it in VBA Editor. I think that this can be useful later, when you know a lot, but not at the beginning. I am looking for any lessons, step by step showing what is neccessary in a macro and what it means. Then more and more functions to write working macros. Having such background I'll be able to learn using other methods. I tried to find anything like this in the Internet to download or use on line, but without any success. I found a lot for Excel but I read that the rules are not the same. Could you please advice me anything suitable for a person who is just starting with writing macros for Word? Thanks again for your help. Regards Tico Użytkownik "Graham Mayor" napisał w wiadomości ... The lines indicated in red have wrapped prematurely use the following which should not wrap Sub DeleteMarkedPages() Selection.HomeKey wdStory Selection.Find.ClearFormatting With Selection.Find Do While .Execute(findText:="\", _ MatchWildcards:=False, _ Wrap:=wdFindContinue, _ Forward:=True) = True Selection.Bookmarks("\page").Range.Delete Loop End With http://www.gmayor.com/installing_macro.htm The macro will remove any page with the \ character in Word 2007 and should work in Word 97 also, though I don't have it available to check. Word 2007 will open a Word document from Word 97 without the need to 'convert' it. -- Graham Mayor - Word MVP My web site www.gmayor.com Word MVP web site http://word.mvps.org Tico wrote: Thank you very much for your prompt reply. Unfortunately I don't know enough about macros to be able to use the macro. When I tried to use it I got the following lines in red: Do While .Execute(FindText:="#*#", MatchWildcards:=False, Wrap:=wdFindContinue, Forward:=True) = True Selection.Bookmarks("\page").Range.Delete regardless what I replaced the "#*#" with. My special character is \. I don't even know what I should writei n the macro: "#\#", "\" or simply \ I haven't found FindText in the "VBA for Dummies" for Office 97 that I have so I think I should save my file as Word 2007 first and then use the macro. I have Office 2007 (home edition) but I am not familiar with it yet, at least not to use macros. I am afraid I'll have to remove the pages manually. :-( Regards Tico Użytkownik "Doug Robbins - Word MVP" napisał w wiadomości ... Use a macro containing the following code where you replace the #*# with the special character that you intend to use. Selection.HomeKey wdStory Selection.Find.ClearFormatting With Selection.Find Do While .Execute(FindText:="#*#", MatchWildcards:=False, Wrap:=wdFindContinue, Forward:=True) = True Selection.Bookmarks("\page").Range.Delete Loop End With -- 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 "Tico" wrote in message ... Hi All, I have a big MS Word 97 file. I am looking for any method that let me remove automatically some pages which I can mark using, for example, a special character as the first on each page or in any other way. I would be also satisfied if I could automatically skip the pages whilst printing the file. I can use the MS Word 2007 to do it, if necessary. Could anyone help me please? The matter is urgent.:-) Regards Tico |
#25
Posted to microsoft.public.word.newusers
|
|||
|
|||
How to remove automatically some pages?
Thank you very much for your propositions. That's very kind of you.
I just wanted to send my example to you but I can't find your e-mail address on your web site www.gmayor.com. :-( I made some progress. I realised that I made a mistake. I put the names of the pages which were prepared to sort manually i.e. with conditions to skip a page when it isn't necessary. That's why I got the warning about using SKIPIF etc. After putting correct names I got some results but not quite good yet. 1) I typed the below {IF {Mergefield Indicatorfieldname} "\" "{Includetext "c:\\path\\page1.doc" ""}{IF {Mergefield Indicatorfieldname} "\" "{Includetext "c:\\path\\page2.doc" ""}{IF {Mergefield Indicatorfieldname} "\" "{Includetext "c:\\path\\page2.doc" ""}etc but only page1 was processed I got the same result when I only typed: {IF {Mergefield Indicatorfieldname} "\" "{Includetext "c:\\path\\page1.doc" ""}} 2) all records in Excel file are processed regardless of value in Excel record (It behaves as if there wasn't the condition "\") Please tell me where is your e-mail address on your web site. I'd like to send you my example and give you my e-mail address and ask you for sending me your sample working document Best regards Tico Użytkownik "Graham Mayor" napisał w wiadomości ... This is complicated enough to explain in English Given that the language problem might then be reversed, I wonder if it would help if you sent me the merge documents so that I can see what you are doing? Zip up the five(?) documents and mail them to the link on my web site. I *may* be able to spot the problem. If you are unable to do that - e-mail me a contact address and I'll send you a sample working document and you can see how it is supposed to work. -- Graham Mayor - Word MVP My web site www.gmayor.com Word MVP web site http://word.mvps.org Tico wrote: Thanks a lot once more. We seem to be talking at cross purposes I am very sorry that my English is so poor. Another problem is that I cannot use English versions of Windows and MS Office so when I want to describe anything I have to translate it into English. From what you have posted earlier, your merge document has five pages (not thousands), some of which will not be required according to the dictates of the data. Right. I'll have thousands of pages as a result of Mailmerge because the Excel file contains thousends (or at least hundreds) of records. You have said that you have a field in the data source which indicates which page will not be required for a given record. Right. Save each of the five pages as a separate document and note the filename and path. Done. Each page contains a table. Besides, fieldnames are rather long so each "source" takes more than 1 page in fact. If it is necessary I could shorten the names of the fields (=names of Excel columns) {IF {Mergefield Indicatorfieldname} "\" "{Includetext "c:\\path\\page1.doc" ""}{IF {Mergefield Indicatorfieldname} "\" "{Includetext "c:\\path\\page2.doc" ""}{IF {Mergefield Indicatorfieldname} "\" "{Includetext "c:\\path\\page2.doc" ""}etc I opened a new Word97 file and then use: Tools MailMerge 1. Create Form Letters Active Window 2. Get Data Open Data Source I opened my Excel file. Then I clicked on the Edit Main Document button. I typed what you wrote using CTRL+F9 (I forgot about it when I tried before). To get Mergefileld Indicatorfieldname I selected it from the Insert Merge Field (left up corner) The paths use double slashes and the names of the files are correct. Afterwards I use: Tools MailMerge 3. Merge button The following options were selected: Merge to a New Document Records to be saved All Without printing empty records Then I clicked on Merge I got the following warning: Microsoft Word You cannot insert the fields DATA, NEXT, NEXTIF or SKIPIF inside other fields (this is my translation) and after clicking on OK I got the following information: MailMerge An error was encountered when counting a value of field in record 1 (this is also my tranaslation) After clicking OK I got just 1 empty page (without inserted values) - the first from 5 pages. Unless the first page of your merge document runs top more than one page, there will only be one page in the merge document - unless the conditions require that the includetext fields include them. I am very sorry but I don't understand it. I suppose it is about what I got but I have language problems with understanding it. Could you please write it more simple, without using the word "unless" which is very difficult to me when I have to understand anything precisely. Sorry. Best regards Tico Użytkownik "Graham Mayor" napisał w wiadomości ... We seem to be talking at cross purposes. From what you have posted earlier, your merge document has five pages (not thousands), some of which will not be required according to the dictates of the data. You have said that you have a field in the data source which indicates which page will not be required for a given record. Save each of the five pages as a separate document and note the filename and path. Then your merge document will contain the conditional fields on the same line eg {IF {Mergefield Indicatorfieldname} "\" "{Includetext "c:\\path\\page1.doc" ""}{IF {Mergefield Indicatorfieldname} "\" "{Includetext "c:\\path\\page2.doc" ""}{IF {Mergefield Indicatorfieldname} "\" "{Includetext "c:\\path\\page2.doc" ""}etc These are fields not simply typed in at the keyboard. Use CTRL+F9 for the brackets, and note that the paths must use double slashes and of course they and the fieldnames must match the actual filenames and fieldnames. Unless the first page of your merge document runs top more than one page, there will only be one page in the merge document - unless the conditions require that the includetext fields include them. When you then merge your database, you will have only the required number of pages for each record. The merge fields in the inserted documents will work as if they were typed on the page. -- Graham Mayor - Word MVP My web site www.gmayor.com Word MVP web site http://word.mvps.org Tico wrote: I read once again your below news and I think that I didn't understand well your advice: "save each page as a separate document" when I tried to use it before. If I have to save each page as a separate document, I'll have to create thousands of files and for each file to include an information about Excel record (number?) in its name. I'm afraid this method would be more complicated and take more time than sorting manually. :-( Regards Tico Użytkownik "Graham Mayor" napisał w wiadomości ... You claim your merge requires a number of pages according to the data. Instead of merging all the pages and deleting the unwanted ones, include only the ones you need according to the requirements of the data ie save each page as a separate document and use includetext to insert only the pages you want. -- Graham Mayor - Word MVP My web site www.gmayor.com Word MVP web site http://word.mvps.org Tico wrote: I am not sure if I understand you well. Do you mean to process for each kind of page separately (as I described in the method with sorting manually) and then to process the MailMerge again just to combine the pages into one file in a proper order? Regards Tico Użytkownik "Graham Mayor" napisał w wiadomości ... From your description you should conditionally insert the pages eg {IF {Mergefield Char} "\" "{IncludeText c:\\path\\page1.doc"}" ""} It is always easier not to add in the pages that you don't need than to remove them later -- Graham Mayor - Word MVP My web site www.gmayor.com Word MVP web site http://word.mvps.org Tico wrote: Sorry, I should have written 5 instead of 3 in my last news. I have 5 kinds of pages however from each record only from 1 to 3 pages can be necessary. In "my" method I "produce" all 5 pages for each Excel record and then I delete unnecessary pages using tha macro from you. Sorting the pages manually I had to repeat the process 5 times however in this case I was able to produce only necessary pages using SKIPIF, of course. But sorting it manually is really a nuisance. I thought about using the "NEXT RECORD IF ..." but in this case I'd have to be able to skip pages in Word. :-( Probably the best way would be to write a "regular" program in Visual Basic or so, but unfortuantely I am not able to. Regards Tico Użytkownik "Tico" napisał w wiadomości ... No because SKIPIF cause to skip a whole record. But I have to "produce" from 1 to 3 possible pages in Word from each record depending on the data in Excel file. That's why I have to "produce" all pages first and then to delete those which are not necessary. I tried to do it another way - I processed the Excel file 3 times and then I sorted the pages manually but in case of big files it is really a nuisance. The order of pages is important. I'll try to solve the problem continuing what I wrote in my prevoius news. I'll try not to center the first line however I don't understand why it worked when I processed it 3 times separately without the extra character. I don't know what causes the difference. Regards Tico Użytkownik "Graham Mayor" napisał w wiadomości ... I am totally bemused now. If you don't want the page(s) with this particular merge record, why are you merging the record in the first place? Wouldn't e.g. {SKIPIF {Mergefield Char} = "\"} work? -- Graham Mayor - Word MVP My web site www.gmayor.com Word MVP web site http://word.mvps.org Tico wrote: The same happens when I put in the Excel file "" instead of " " when I want a page not to be deleted. I think it is somehow connected with the sign of new page because sometimes it is OK but always after another sign of new page. However i don't know how to force a correct sign in the MaiMerge. Regards Tico Użytkownik "Tico" napisał w wiadomości ... I understand. I thought that everything was OK but I have one problem: the additional character damages to keeping a part of the first line in the center. I put in Excel file an addition column and the character "\" is put in it, if the page in Word should be deleted or the character " ", if the page in Word should'n be deleted. What is put : "\" or " " depends on other values in Excel file. Everything is OK but the first line on pages with " " is moved much more to the left than the 1 character (" ") should use (the same happens to pages with "\" but it is not important as they are deleted afterwards). The first line on each page consists of the constant text and a number that is put during the MailMerge process, like this ABCDEF GHIJ KLMNOP {MERGEFIELD No} The text should be in the center of the page, and the No on the right side. After I added the character it looks like this: {MERGEFIELD Char}ABCDEF GHIJ KLMNOP {MERGEFIELD No} (Before I put the additional character everything was OK and the constant text was in the center) My MailMerge "source" file consist of 5 pages, not just one. After the process of MailMerging I delete the "extra" pages using the macro from you. Each of the "source" 5 pages has similar first line as I described above. Could you help me once more, please? Regards Tico Użytkownik "Graham Mayor" napisał w wiadomości ... Page is a vague concept in Word which is not a page layout application and if you remove pages the document reflows to create a new 'page' structure. -- Graham Mayor - Word MVP My web site www.gmayor.com Word MVP web site http://word.mvps.org Tico wrote: Thank you both very, very much once again. I used the macro to the big MailMerge output file and it works perfectly. The macro would work faster if it could test just the first character on each page but I don't know how to change it. But it works very well and I am very grateful. As for a tutorial I expected something I had when I learnt other languages which began with "Hello World" or something like this. Then, step by step, it showed how to use more and more complicated language tools. Regards Tico Użytkownik "Graham Mayor" napisał w wiadomości ... If you are splitting the results of a mail merge, see http://www.gmayor.com/individual_merge_letters.htm As Doug says, the only way to learn vba is to put it to use to perform simple tasks and then get more adventurous. You can always use the macro recorder to give you some ideas. It is by no means perfect but it does help get you started. You will find lots of coding examples in the vba programming forums and on various web site, including my own. The vba help in Word 2007 is rather better than in earlier versions. -- Graham Mayor - Word MVP My web site www.gmayor.com Word MVP web site http://word.mvps.org Tico wrote: Thank you very, very much. I created a sample file and it works! Now I have to put the macro into my big file which is a result of MailMerge and make a lot of tests. By the way, I know almost nothing about VBA for Word. I looked at your page and I found a lot of interesting things there. However what I need most at the moment is any tutorial how to create simple macros in Word from the very beginning. Not just examples, which are important too, but first of all the most basic rules. I read that one of ways is to record macros using Word and then to analyse it in VBA Editor. I think that this can be useful later, when you know a lot, but not at the beginning. I am looking for any lessons, step by step showing what is neccessary in a macro and what it means. Then more and more functions to write working macros. Having such background I'll be able to learn using other methods. I tried to find anything like this in the Internet to download or use on line, but without any success. I found a lot for Excel but I read that the rules are not the same. Could you please advice me anything suitable for a person who is just starting with writing macros for Word? Thanks again for your help. Regards Tico Użytkownik "Graham Mayor" napisał w wiadomości ... The lines indicated in red have wrapped prematurely use the following which should not wrap Sub DeleteMarkedPages() Selection.HomeKey wdStory Selection.Find.ClearFormatting With Selection.Find Do While .Execute(findText:="\", _ MatchWildcards:=False, _ Wrap:=wdFindContinue, _ Forward:=True) = True Selection.Bookmarks("\page").Range.Delete Loop End With http://www.gmayor.com/installing_macro.htm The macro will remove any page with the \ character in Word 2007 and should work in Word 97 also, though I don't have it available to check. Word 2007 will open a Word document from Word 97 without the need to 'convert' it. -- Graham Mayor - Word MVP My web site www.gmayor.com Word MVP web site http://word.mvps.org Tico wrote: Thank you very much for your prompt reply. Unfortunately I don't know enough about macros to be able to use the macro. When I tried to use it I got the following lines in red: Do While .Execute(FindText:="#*#", MatchWildcards:=False, Wrap:=wdFindContinue, Forward:=True) = True Selection.Bookmarks("\page").Range.Delete regardless what I replaced the "#*#" with. My special character is \. I don't even know what I should writei n the macro: "#\#", "\" or simply \ I haven't found FindText in the "VBA for Dummies" for Office 97 that I have so I think I should save my file as Word 2007 first and then use the macro. I have Office 2007 (home edition) but I am not familiar with it yet, at least not to use macros. I am afraid I'll have to remove the pages manually. :-( Regards Tico Użytkownik "Doug Robbins - Word MVP" napisał w wiadomości ... Use a macro containing the following code where you replace the #*# with the special character that you intend to use. Selection.HomeKey wdStory Selection.Find.ClearFormatting With Selection.Find Do While .Execute(FindText:="#*#", MatchWildcards:=False, Wrap:=wdFindContinue, Forward:=True) = True Selection.Bookmarks("\page").Range.Delete Loop End With -- 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 "Tico" wrote in message ... Hi All, I have a big MS Word 97 file. I am looking for any method that let me remove automatically some pages which I can mark using, for example, a special character as the first on each page or in any other way. I would be also satisfied if I could automatically skip the pages whilst printing the file. I can use the MS Word 2007 to do it, if necessary. Could anyone help me please? The matter is urgent.:-) Regards Tico |
#26
Posted to microsoft.public.word.newusers
|
|||
|
|||
How to remove automatically some pages?
I sent my exaple to you using your address at mvps.org.
Best regards Tico Użytkownik "Tico" napisał w wiadomości ... Thank you very much for your propositions. That's very kind of you. I just wanted to send my example to you but I can't find your e-mail address on your web site www.gmayor.com. :-( I made some progress. I realised that I made a mistake. I put the names of the pages which were prepared to sort manually i.e. with conditions to skip a page when it isn't necessary. That's why I got the warning about using SKIPIF etc. After putting correct names I got some results but not quite good yet. 1) I typed the below {IF {Mergefield Indicatorfieldname} "\" "{Includetext "c:\\path\\page1.doc" ""}{IF {Mergefield Indicatorfieldname} "\" "{Includetext "c:\\path\\page2.doc" ""}{IF {Mergefield Indicatorfieldname} "\" "{Includetext "c:\\path\\page2.doc" ""}etc but only page1 was processed I got the same result when I only typed: {IF {Mergefield Indicatorfieldname} "\" "{Includetext "c:\\path\\page1.doc" ""}} 2) all records in Excel file are processed regardless of value in Excel record (It behaves as if there wasn't the condition "\") Please tell me where is your e-mail address on your web site. I'd like to send you my example and give you my e-mail address and ask you for sending me your sample working document Best regards Tico Użytkownik "Graham Mayor" napisał w wiadomości ... This is complicated enough to explain in English Given that the language problem might then be reversed, I wonder if it would help if you sent me the merge documents so that I can see what you are doing? Zip up the five(?) documents and mail them to the link on my web site. I *may* be able to spot the problem. If you are unable to do that - e-mail me a contact address and I'll send you a sample working document and you can see how it is supposed to work. -- Graham Mayor - Word MVP My web site www.gmayor.com Word MVP web site http://word.mvps.org Tico wrote: Thanks a lot once more. We seem to be talking at cross purposes I am very sorry that my English is so poor. Another problem is that I cannot use English versions of Windows and MS Office so when I want to describe anything I have to translate it into English. From what you have posted earlier, your merge document has five pages (not thousands), some of which will not be required according to the dictates of the data. Right. I'll have thousands of pages as a result of Mailmerge because the Excel file contains thousends (or at least hundreds) of records. You have said that you have a field in the data source which indicates which page will not be required for a given record. Right. Save each of the five pages as a separate document and note the filename and path. Done. Each page contains a table. Besides, fieldnames are rather long so each "source" takes more than 1 page in fact. If it is necessary I could shorten the names of the fields (=names of Excel columns) {IF {Mergefield Indicatorfieldname} "\" "{Includetext "c:\\path\\page1.doc" ""}{IF {Mergefield Indicatorfieldname} "\" "{Includetext "c:\\path\\page2.doc" ""}{IF {Mergefield Indicatorfieldname} "\" "{Includetext "c:\\path\\page2.doc" ""}etc I opened a new Word97 file and then use: Tools MailMerge 1. Create Form Letters Active Window 2. Get Data Open Data Source I opened my Excel file. Then I clicked on the Edit Main Document button. I typed what you wrote using CTRL+F9 (I forgot about it when I tried before). To get Mergefileld Indicatorfieldname I selected it from the Insert Merge Field (left up corner) The paths use double slashes and the names of the files are correct. Afterwards I use: Tools MailMerge 3. Merge button The following options were selected: Merge to a New Document Records to be saved All Without printing empty records Then I clicked on Merge I got the following warning: Microsoft Word You cannot insert the fields DATA, NEXT, NEXTIF or SKIPIF inside other fields (this is my translation) and after clicking on OK I got the following information: MailMerge An error was encountered when counting a value of field in record 1 (this is also my tranaslation) After clicking OK I got just 1 empty page (without inserted values) - the first from 5 pages. Unless the first page of your merge document runs top more than one page, there will only be one page in the merge document - unless the conditions require that the includetext fields include them. I am very sorry but I don't understand it. I suppose it is about what I got but I have language problems with understanding it. Could you please write it more simple, without using the word "unless" which is very difficult to me when I have to understand anything precisely. Sorry. Best regards Tico Użytkownik "Graham Mayor" napisał w wiadomości ... We seem to be talking at cross purposes. From what you have posted earlier, your merge document has five pages (not thousands), some of which will not be required according to the dictates of the data. You have said that you have a field in the data source which indicates which page will not be required for a given record. Save each of the five pages as a separate document and note the filename and path. Then your merge document will contain the conditional fields on the same line eg {IF {Mergefield Indicatorfieldname} "\" "{Includetext "c:\\path\\page1.doc" ""}{IF {Mergefield Indicatorfieldname} "\" "{Includetext "c:\\path\\page2.doc" ""}{IF {Mergefield Indicatorfieldname} "\" "{Includetext "c:\\path\\page2.doc" ""}etc These are fields not simply typed in at the keyboard. Use CTRL+F9 for the brackets, and note that the paths must use double slashes and of course they and the fieldnames must match the actual filenames and fieldnames. Unless the first page of your merge document runs top more than one page, there will only be one page in the merge document - unless the conditions require that the includetext fields include them. When you then merge your database, you will have only the required number of pages for each record. The merge fields in the inserted documents will work as if they were typed on the page. -- Graham Mayor - Word MVP My web site www.gmayor.com Word MVP web site http://word.mvps.org Tico wrote: I read once again your below news and I think that I didn't understand well your advice: "save each page as a separate document" when I tried to use it before. If I have to save each page as a separate document, I'll have to create thousands of files and for each file to include an information about Excel record (number?) in its name. I'm afraid this method would be more complicated and take more time than sorting manually. :-( Regards Tico Użytkownik "Graham Mayor" napisał w wiadomości ... You claim your merge requires a number of pages according to the data. Instead of merging all the pages and deleting the unwanted ones, include only the ones you need according to the requirements of the data ie save each page as a separate document and use includetext to insert only the pages you want. -- Graham Mayor - Word MVP My web site www.gmayor.com Word MVP web site http://word.mvps.org Tico wrote: I am not sure if I understand you well. Do you mean to process for each kind of page separately (as I described in the method with sorting manually) and then to process the MailMerge again just to combine the pages into one file in a proper order? Regards Tico Użytkownik "Graham Mayor" napisał w wiadomości ... From your description you should conditionally insert the pages eg {IF {Mergefield Char} "\" "{IncludeText c:\\path\\page1.doc"}" ""} It is always easier not to add in the pages that you don't need than to remove them later -- Graham Mayor - Word MVP My web site www.gmayor.com Word MVP web site http://word.mvps.org Tico wrote: Sorry, I should have written 5 instead of 3 in my last news. I have 5 kinds of pages however from each record only from 1 to 3 pages can be necessary. In "my" method I "produce" all 5 pages for each Excel record and then I delete unnecessary pages using tha macro from you. Sorting the pages manually I had to repeat the process 5 times however in this case I was able to produce only necessary pages using SKIPIF, of course. But sorting it manually is really a nuisance. I thought about using the "NEXT RECORD IF ..." but in this case I'd have to be able to skip pages in Word. :-( Probably the best way would be to write a "regular" program in Visual Basic or so, but unfortuantely I am not able to. Regards Tico Użytkownik "Tico" napisał w wiadomości ... No because SKIPIF cause to skip a whole record. But I have to "produce" from 1 to 3 possible pages in Word from each record depending on the data in Excel file. That's why I have to "produce" all pages first and then to delete those which are not necessary. I tried to do it another way - I processed the Excel file 3 times and then I sorted the pages manually but in case of big files it is really a nuisance. The order of pages is important. I'll try to solve the problem continuing what I wrote in my prevoius news. I'll try not to center the first line however I don't understand why it worked when I processed it 3 times separately without the extra character. I don't know what causes the difference. Regards Tico Użytkownik "Graham Mayor" napisał w wiadomości ... I am totally bemused now. If you don't want the page(s) with this particular merge record, why are you merging the record in the first place? Wouldn't e.g. {SKIPIF {Mergefield Char} = "\"} work? -- Graham Mayor - Word MVP My web site www.gmayor.com Word MVP web site http://word.mvps.org Tico wrote: The same happens when I put in the Excel file "" instead of " " when I want a page not to be deleted. I think it is somehow connected with the sign of new page because sometimes it is OK but always after another sign of new page. However i don't know how to force a correct sign in the MaiMerge. Regards Tico Użytkownik "Tico" napisał w wiadomości ... I understand. I thought that everything was OK but I have one problem: the additional character damages to keeping a part of the first line in the center. I put in Excel file an addition column and the character "\" is put in it, if the page in Word should be deleted or the character " ", if the page in Word should'n be deleted. What is put : "\" or " " depends on other values in Excel file. Everything is OK but the first line on pages with " " is moved much more to the left than the 1 character (" ") should use (the same happens to pages with "\" but it is not important as they are deleted afterwards). The first line on each page consists of the constant text and a number that is put during the MailMerge process, like this ABCDEF GHIJ KLMNOP {MERGEFIELD No} The text should be in the center of the page, and the No on the right side. After I added the character it looks like this: {MERGEFIELD Char}ABCDEF GHIJ KLMNOP {MERGEFIELD No} (Before I put the additional character everything was OK and the constant text was in the center) My MailMerge "source" file consist of 5 pages, not just one. After the process of MailMerging I delete the "extra" pages using the macro from you. Each of the "source" 5 pages has similar first line as I described above. Could you help me once more, please? Regards Tico Użytkownik "Graham Mayor" napisał w wiadomości ... Page is a vague concept in Word which is not a page layout application and if you remove pages the document reflows to create a new 'page' structure. -- Graham Mayor - Word MVP My web site www.gmayor.com Word MVP web site http://word.mvps.org Tico wrote: Thank you both very, very much once again. I used the macro to the big MailMerge output file and it works perfectly. The macro would work faster if it could test just the first character on each page but I don't know how to change it. But it works very well and I am very grateful. As for a tutorial I expected something I had when I learnt other languages which began with "Hello World" or something like this. Then, step by step, it showed how to use more and more complicated language tools. Regards Tico Użytkownik "Graham Mayor" napisał w wiadomości ... If you are splitting the results of a mail merge, see http://www.gmayor.com/individual_merge_letters.htm As Doug says, the only way to learn vba is to put it to use to perform simple tasks and then get more adventurous. You can always use the macro recorder to give you some ideas. It is by no means perfect but it does help get you started. You will find lots of coding examples in the vba programming forums and on various web site, including my own. The vba help in Word 2007 is rather better than in earlier versions. -- Graham Mayor - Word MVP My web site www.gmayor.com Word MVP web site http://word.mvps.org Tico wrote: Thank you very, very much. I created a sample file and it works! Now I have to put the macro into my big file which is a result of MailMerge and make a lot of tests. By the way, I know almost nothing about VBA for Word. I looked at your page and I found a lot of interesting things there. However what I need most at the moment is any tutorial how to create simple macros in Word from the very beginning. Not just examples, which are important too, but first of all the most basic rules. I read that one of ways is to record macros using Word and then to analyse it in VBA Editor. I think that this can be useful later, when you know a lot, but not at the beginning. I am looking for any lessons, step by step showing what is neccessary in a macro and what it means. Then more and more functions to write working macros. Having such background I'll be able to learn using other methods. I tried to find anything like this in the Internet to download or use on line, but without any success. I found a lot for Excel but I read that the rules are not the same. Could you please advice me anything suitable for a person who is just starting with writing macros for Word? Thanks again for your help. Regards Tico Użytkownik "Graham Mayor" napisał w wiadomości ... The lines indicated in red have wrapped prematurely use the following which should not wrap Sub DeleteMarkedPages() Selection.HomeKey wdStory Selection.Find.ClearFormatting With Selection.Find Do While .Execute(findText:="\", _ MatchWildcards:=False, _ Wrap:=wdFindContinue, _ Forward:=True) = True Selection.Bookmarks("\page").Range.Delete Loop End With http://www.gmayor.com/installing_macro.htm The macro will remove any page with the \ character in Word 2007 and should work in Word 97 also, though I don't have it available to check. Word 2007 will open a Word document from Word 97 without the need to 'convert' it. -- Graham Mayor - Word MVP My web site www.gmayor.com Word MVP web site http://word.mvps.org Tico wrote: Thank you very much for your prompt reply. Unfortunately I don't know enough about macros to be able to use the macro. When I tried to use it I got the following lines in red: Do While .Execute(FindText:="#*#", MatchWildcards:=False, Wrap:=wdFindContinue, Forward:=True) = True Selection.Bookmarks("\page").Range.Delete regardless what I replaced the "#*#" with. My special character is \. I don't even know what I should writei n the macro: "#\#", "\" or simply \ I haven't found FindText in the "VBA for Dummies" for Office 97 that I have so I think I should save my file as Word 2007 first and then use the macro. I have Office 2007 (home edition) but I am not familiar with it yet, at least not to use macros. I am afraid I'll have to remove the pages manually. :-( Regards Tico Użytkownik "Doug Robbins - Word MVP" napisał w wiadomości ... Use a macro containing the following code where you replace the #*# with the special character that you intend to use. Selection.HomeKey wdStory Selection.Find.ClearFormatting With Selection.Find Do While .Execute(FindText:="#*#", MatchWildcards:=False, Wrap:=wdFindContinue, Forward:=True) = True Selection.Bookmarks("\page").Range.Delete Loop End With -- 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 "Tico" wrote in message ... Hi All, I have a big MS Word 97 file. I am looking for any method that let me remove automatically some pages which I can mark using, for example, a special character as the first on each page or in any other way. I would be also satisfied if I could automatically skip the pages whilst printing the file. I can use the MS Word 2007 to do it, if necessary. Could anyone help me please? The matter is urgent.:-) Regards Tico |
#27
Posted to microsoft.public.word.newusers
|
|||
|
|||
How to remove automatically some pages?
My e-mail link is on the home page of my web site. Messages sent to my MVPS
address are likely to be swallowed by the spam filter, but I rescued this one I have replied to your e-mail, but for the benefit of others who may be watching the problem was a minor issue with your syntax in that you put some of the field content in the rworng place with respect to the fields. When this is corrected your document works. You had { IF { MERGEFIELD I } "\" "{ Includetext "c:\\test\\Sz_I.doc" "" }{ IF { MERGEFIELD II_bez } "\" "{ Includetext "c:\\test\\Sz_II.doc" "" }{ IF { MERGEFIELD II_str } "\" "{ Includetext "c:\\test\\Sz_II_s.doc" "" }{ IF { MERGEFIELD III_bez } "\" "{ Includetext "c:\\test\\Sz_III.doc" "" }{ IF { MERGEFIELD III_str } "\" "{ Includetext "c:\\test\\Sz_III_s.doc" ""}}}}}} and it should be { IF { MERGEFIELD I } "\" "{ Includetext "c:\\test\\Sz_I.doc" } "" \* MERGEFORMAT }{ IF { MERGEFIELD II_bez } "\" "{ Includetext "c:\\test\\Sz_II.doc" } "" \* MERGEFORMAT }{ IF { MERGEFIELD II_str } "\" "{ Includetext "c:\\test\\Sz_II_s.doc" } "" \* MERGEFORMAT }{ IF { MERGEFIELD III_bez } "\" "{ Includetext "c:\\test\\Sz_III.doc" } "" \* MERGEFORMAT }{ IF { MERGEFIELD III_str } "\" "{ Includetext "c:\\test\\Sz_III_s.doc" } "" \* MERGEFORMAT } Some of the field names in your data file had spaces whereas in the fields they correctly had underscores. You would need to change the data source to match the fields. The mergeformat switches may not be necessary but they are probably desirable. -- Graham Mayor - Word MVP My web site www.gmayor.com Word MVP web site http://word.mvps.org Tico wrote: I sent my exaple to you using your address at mvps.org. Best regards Tico Użytkownik "Tico" napisał w wiadomości ... Thank you very much for your propositions. That's very kind of you. I just wanted to send my example to you but I can't find your e-mail address on your web site www.gmayor.com. :-( I made some progress. I realised that I made a mistake. I put the names of the pages which were prepared to sort manually i.e. with conditions to skip a page when it isn't necessary. That's why I got the warning about using SKIPIF etc. After putting correct names I got some results but not quite good yet. 1) I typed the below {IF {Mergefield Indicatorfieldname} "\" "{Includetext "c:\\path\\page1.doc" ""}{IF {Mergefield Indicatorfieldname} "\" "{Includetext "c:\\path\\page2.doc" ""}{IF {Mergefield Indicatorfieldname} "\" "{Includetext "c:\\path\\page2.doc" ""}etc but only page1 was processed I got the same result when I only typed: {IF {Mergefield Indicatorfieldname} "\" "{Includetext "c:\\path\\page1.doc" ""}} 2) all records in Excel file are processed regardless of value in Excel record (It behaves as if there wasn't the condition "\") Please tell me where is your e-mail address on your web site. I'd like to send you my example and give you my e-mail address and ask you for sending me your sample working document Best regards Tico Użytkownik "Graham Mayor" napisał w wiadomości ... This is complicated enough to explain in English Given that the language problem might then be reversed, I wonder if it would help if you sent me the merge documents so that I can see what you are doing? Zip up the five(?) documents and mail them to the link on my web site. I *may* be able to spot the problem. If you are unable to do that - e-mail me a contact address and I'll send you a sample working document and you can see how it is supposed to work. -- Graham Mayor - Word MVP My web site www.gmayor.com Word MVP web site http://word.mvps.org Tico wrote: Thanks a lot once more. We seem to be talking at cross purposes I am very sorry that my English is so poor. Another problem is that I cannot use English versions of Windows and MS Office so when I want to describe anything I have to translate it into English. From what you have posted earlier, your merge document has five pages (not thousands), some of which will not be required according to the dictates of the data. Right. I'll have thousands of pages as a result of Mailmerge because the Excel file contains thousends (or at least hundreds) of records. You have said that you have a field in the data source which indicates which page will not be required for a given record. Right. Save each of the five pages as a separate document and note the filename and path. Done. Each page contains a table. Besides, fieldnames are rather long so each "source" takes more than 1 page in fact. If it is necessary I could shorten the names of the fields (=names of Excel columns) {IF {Mergefield Indicatorfieldname} "\" "{Includetext "c:\\path\\page1.doc" ""}{IF {Mergefield Indicatorfieldname} "\" "{Includetext "c:\\path\\page2.doc" ""}{IF {Mergefield Indicatorfieldname} "\" "{Includetext "c:\\path\\page2.doc" ""}etc I opened a new Word97 file and then use: Tools MailMerge 1. Create Form Letters Active Window 2. Get Data Open Data Source I opened my Excel file. Then I clicked on the Edit Main Document button. I typed what you wrote using CTRL+F9 (I forgot about it when I tried before). To get Mergefileld Indicatorfieldname I selected it from the Insert Merge Field (left up corner) The paths use double slashes and the names of the files are correct. Afterwards I use: Tools MailMerge 3. Merge button The following options were selected: Merge to a New Document Records to be saved All Without printing empty records Then I clicked on Merge I got the following warning: Microsoft Word You cannot insert the fields DATA, NEXT, NEXTIF or SKIPIF inside other fields (this is my translation) and after clicking on OK I got the following information: MailMerge An error was encountered when counting a value of field in record 1 (this is also my tranaslation) After clicking OK I got just 1 empty page (without inserted values) - the first from 5 pages. Unless the first page of your merge document runs top more than one page, there will only be one page in the merge document - unless the conditions require that the includetext fields include them. I am very sorry but I don't understand it. I suppose it is about what I got but I have language problems with understanding it. Could you please write it more simple, without using the word "unless" which is very difficult to me when I have to understand anything precisely. Sorry. Best regards Tico Użytkownik "Graham Mayor" napisał w wiadomości ... We seem to be talking at cross purposes. From what you have posted earlier, your merge document has five pages (not thousands), some of which will not be required according to the dictates of the data. You have said that you have a field in the data source which indicates which page will not be required for a given record. Save each of the five pages as a separate document and note the filename and path. Then your merge document will contain the conditional fields on the same line eg {IF {Mergefield Indicatorfieldname} "\" "{Includetext "c:\\path\\page1.doc" ""}{IF {Mergefield Indicatorfieldname} "\" "{Includetext "c:\\path\\page2.doc" ""}{IF {Mergefield Indicatorfieldname} "\" "{Includetext "c:\\path\\page2.doc" ""}etc These are fields not simply typed in at the keyboard. Use CTRL+F9 for the brackets, and note that the paths must use double slashes and of course they and the fieldnames must match the actual filenames and fieldnames. Unless the first page of your merge document runs top more than one page, there will only be one page in the merge document - unless the conditions require that the includetext fields include them. When you then merge your database, you will have only the required number of pages for each record. The merge fields in the inserted documents will work as if they were typed on the page. -- Graham Mayor - Word MVP My web site www.gmayor.com Word MVP web site http://word.mvps.org Tico wrote: I read once again your below news and I think that I didn't understand well your advice: "save each page as a separate document" when I tried to use it before. If I have to save each page as a separate document, I'll have to create thousands of files and for each file to include an information about Excel record (number?) in its name. I'm afraid this method would be more complicated and take more time than sorting manually. :-( Regards Tico Użytkownik "Graham Mayor" napisał w wiadomości ... You claim your merge requires a number of pages according to the data. Instead of merging all the pages and deleting the unwanted ones, include only the ones you need according to the requirements of the data ie save each page as a separate document and use includetext to insert only the pages you want. -- Graham Mayor - Word MVP My web site www.gmayor.com Word MVP web site http://word.mvps.org Tico wrote: I am not sure if I understand you well. Do you mean to process for each kind of page separately (as I described in the method with sorting manually) and then to process the MailMerge again just to combine the pages into one file in a proper order? Regards Tico Użytkownik "Graham Mayor" napisał w wiadomości ... From your description you should conditionally insert the pages eg {IF {Mergefield Char} "\" "{IncludeText c:\\path\\page1.doc"}" ""} It is always easier not to add in the pages that you don't need than to remove them later -- Graham Mayor - Word MVP My web site www.gmayor.com Word MVP web site http://word.mvps.org Tico wrote: Sorry, I should have written 5 instead of 3 in my last news. I have 5 kinds of pages however from each record only from 1 to 3 pages can be necessary. In "my" method I "produce" all 5 pages for each Excel record and then I delete unnecessary pages using tha macro from you. Sorting the pages manually I had to repeat the process 5 times however in this case I was able to produce only necessary pages using SKIPIF, of course. But sorting it manually is really a nuisance. I thought about using the "NEXT RECORD IF ..." but in this case I'd have to be able to skip pages in Word. :-( Probably the best way would be to write a "regular" program in Visual Basic or so, but unfortuantely I am not able to. Regards Tico Użytkownik "Tico" napisał w wiadomości ... No because SKIPIF cause to skip a whole record. But I have to "produce" from 1 to 3 possible pages in Word from each record depending on the data in Excel file. That's why I have to "produce" all pages first and then to delete those which are not necessary. I tried to do it another way - I processed the Excel file 3 times and then I sorted the pages manually but in case of big files it is really a nuisance. The order of pages is important. I'll try to solve the problem continuing what I wrote in my prevoius news. I'll try not to center the first line however I don't understand why it worked when I processed it 3 times separately without the extra character. I don't know what causes the difference. Regards Tico Użytkownik "Graham Mayor" napisał w wiadomości ... I am totally bemused now. If you don't want the page(s) with this particular merge record, why are you merging the record in the first place? Wouldn't e.g. {SKIPIF {Mergefield Char} = "\"} work? -- Graham Mayor - Word MVP My web site www.gmayor.com Word MVP web site http://word.mvps.org Tico wrote: The same happens when I put in the Excel file "" instead of " " when I want a page not to be deleted. I think it is somehow connected with the sign of new page because sometimes it is OK but always after another sign of new page. However i don't know how to force a correct sign in the MaiMerge. Regards Tico Użytkownik "Tico" napisał w wiadomości ... I understand. I thought that everything was OK but I have one problem: the additional character damages to keeping a part of the first line in the center. I put in Excel file an addition column and the character "\" is put in it, if the page in Word should be deleted or the character " ", if the page in Word should'n be deleted. What is put : "\" or " " depends on other values in Excel file. Everything is OK but the first line on pages with " " is moved much more to the left than the 1 character (" ") should use (the same happens to pages with "\" but it is not important as they are deleted afterwards). The first line on each page consists of the constant text and a number that is put during the MailMerge process, like this ABCDEF GHIJ KLMNOP {MERGEFIELD No} The text should be in the center of the page, and the No on the right side. After I added the character it looks like this: {MERGEFIELD Char}ABCDEF GHIJ KLMNOP {MERGEFIELD No} (Before I put the additional character everything was OK and the constant text was in the center) My MailMerge "source" file consist of 5 pages, not just one. After the process of MailMerging I delete the "extra" pages using the macro from you. Each of the "source" 5 pages has similar first line as I described above. Could you help me once more, please? Regards Tico Użytkownik "Graham Mayor" napisał w wiadomości ... Page is a vague concept in Word which is not a page layout application and if you remove pages the document reflows to create a new 'page' structure. -- Graham Mayor - Word MVP My web site www.gmayor.com Word MVP web site http://word.mvps.org Tico wrote: Thank you both very, very much once again. I used the macro to the big MailMerge output file and it works perfectly. The macro would work faster if it could test just the first character on each page but I don't know how to change it. But it works very well and I am very grateful. As for a tutorial I expected something I had when I learnt other languages which began with "Hello World" or something like this. Then, step by step, it showed how to use more and more complicated language tools. Regards Tico Użytkownik "Graham Mayor" napisał w wiadomości ... If you are splitting the results of a mail merge, see http://www.gmayor.com/individual_merge_letters.htm As Doug says, the only way to learn vba is to put it to use to perform simple tasks and then get more adventurous. You can always use the macro recorder to give you some ideas. It is by no means perfect but it does help get you started. You will find lots of coding examples in the vba programming forums and on various web site, including my own. The vba help in Word 2007 is rather better than in earlier versions. -- Graham Mayor - Word MVP My web site www.gmayor.com Word MVP web site http://word.mvps.org Tico wrote: Thank you very, very much. I created a sample file and it works! Now I have to put the macro into my big file which is a result of MailMerge and make a lot of tests. By the way, I know almost nothing about VBA for Word. I looked at your page and I found a lot of interesting things there. However what I need most at the moment is any tutorial how to create simple macros in Word from the very beginning. Not just examples, which are important too, but first of all the most basic rules. I read that one of ways is to record macros using Word and then to analyse it in VBA Editor. I think that this can be useful later, when you know a lot, but not at the beginning. I am looking for any lessons, step by step showing what is neccessary in a macro and what it means. Then more and more functions to write working macros. Having such background I'll be able to learn using other methods. I tried to find anything like this in the Internet to download or use on line, but without any success. I found a lot for Excel but I read that the rules are not the same. Could you please advice me anything suitable for a person who is just starting with writing macros for Word? Thanks again for your help. Regards Tico Użytkownik "Graham Mayor" napisał w wiadomości ... The lines indicated in red have wrapped prematurely use the following which should not wrap Sub DeleteMarkedPages() Selection.HomeKey wdStory Selection.Find.ClearFormatting With Selection.Find Do While .Execute(findText:="\", _ MatchWildcards:=False, _ Wrap:=wdFindContinue, _ Forward:=True) = True Selection.Bookmarks("\page").Range.Delete Loop End With http://www.gmayor.com/installing_macro.htm The macro will remove any page with the \ character in Word 2007 and should work in Word 97 also, though I don't have it available to check. Word 2007 will open a Word document from Word 97 without the need to 'convert' it. -- Graham Mayor - Word MVP My web site www.gmayor.com Word MVP web site http://word.mvps.org Tico wrote: Thank you very much for your prompt reply. Unfortunately I don't know enough about macros to be able to use the macro. When I tried to use it I got the following lines in red: Do While .Execute(FindText:="#*#", MatchWildcards:=False, Wrap:=wdFindContinue, Forward:=True) = True Selection.Bookmarks("\page").Range.Delete regardless what I replaced the "#*#" with. My special character is \. I don't even know what I should writei n the macro: "#\#", "\" or simply \ I haven't found FindText in the "VBA for Dummies" for Office 97 that I have so I think I should save my file as Word 2007 first and then use the macro. I have Office 2007 (home edition) but I am not familiar with it yet, at least not to use macros. I am afraid I'll have to remove the pages manually. :-( Regards Tico Użytkownik "Doug Robbins - Word MVP" napisał w wiadomości ... Use a macro containing the following code where you replace the #*# with the special character that you intend to use. Selection.HomeKey wdStory Selection.Find.ClearFormatting With Selection.Find Do While .Execute(FindText:="#*#", MatchWildcards:=False, Wrap:=wdFindContinue, Forward:=True) = True Selection.Bookmarks("\page").Range.Delete Loop End With -- 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 "Tico" wrote in message ... Hi All, I have a big MS Word 97 file. I am looking for any method that let me remove automatically some pages which I can mark using, for example, a special character as the first on each page or in any other way. I would be also satisfied if I could automatically skip the pages whilst printing the file. I can use the MS Word 2007 to do it, if necessary. Could anyone help me please? The matter is urgent.:-) Regards Tico |
#28
Posted to microsoft.public.word.newusers
|
|||
|
|||
How to remove automatically some pages?
Thank you very much.
My e-mail link is on the home page of my web site. I still can't see it there. Sorry. Messages sent to my MVPS address are likely to be swallowed by the spam filter, but I rescued this one As I don't know if I can write there again, I am answering here. I used the .doc from you and I replaced the spaces in the field names with underscores. At the moment all 5 pages are processed but the condition "\" is still not checked so I get 40 pages as result (8 records in my example by 5 pages). Besides, there is not correct page break in the output .doc so the text that should be on the second page begins on the first one and so on. If you could help me once more, I'd be very grateful. I didn't know what to do to get correct results so I had to use the method with manual sorting again. :-( However I have still 3 of 14 "regions" to process. I regret that I didn't send my question to the group earlier. As you know I thought about removing unnecessary pages first and then you gave me the idea of putting only necessary pages. The task like this is not my usual job but I promised my collagues to do it and I cannot postpone it. Best regards Tico Użytkownik "Graham Mayor" napisał w wiadomości ... My e-mail link is on the home page of my web site. Messages sent to my MVPS address are likely to be swallowed by the spam filter, but I rescued this one I have replied to your e-mail, but for the benefit of others who may be watching the problem was a minor issue with your syntax in that you put some of the field content in the rworng place with respect to the fields. When this is corrected your document works. You had { IF { MERGEFIELD I } "\" "{ Includetext "c:\\test\\Sz_I.doc" "" }{ IF { MERGEFIELD II_bez } "\" "{ Includetext "c:\\test\\Sz_II.doc" "" }{ IF { MERGEFIELD II_str } "\" "{ Includetext "c:\\test\\Sz_II_s.doc" "" }{ IF { MERGEFIELD III_bez } "\" "{ Includetext "c:\\test\\Sz_III.doc" "" }{ IF { MERGEFIELD III_str } "\" "{ Includetext "c:\\test\\Sz_III_s.doc" ""}}}}}} and it should be { IF { MERGEFIELD I } "\" "{ Includetext "c:\\test\\Sz_I.doc" } "" \* MERGEFORMAT }{ IF { MERGEFIELD II_bez } "\" "{ Includetext "c:\\test\\Sz_II.doc" } "" \* MERGEFORMAT }{ IF { MERGEFIELD II_str } "\" "{ Includetext "c:\\test\\Sz_II_s.doc" } "" \* MERGEFORMAT }{ IF { MERGEFIELD III_bez } "\" "{ Includetext "c:\\test\\Sz_III.doc" } "" \* MERGEFORMAT }{ IF { MERGEFIELD III_str } "\" "{ Includetext "c:\\test\\Sz_III_s.doc" } "" \* MERGEFORMAT } Some of the field names in your data file had spaces whereas in the fields they correctly had underscores. You would need to change the data source to match the fields. The mergeformat switches may not be necessary but they are probably desirable. -- Graham Mayor - Word MVP My web site www.gmayor.com Word MVP web site http://word.mvps.org Tico wrote: I sent my exaple to you using your address at mvps.org. Best regards Tico Użytkownik "Tico" napisał w wiadomości ... Thank you very much for your propositions. That's very kind of you. I just wanted to send my example to you but I can't find your e-mail address on your web site www.gmayor.com. :-( I made some progress. I realised that I made a mistake. I put the names of the pages which were prepared to sort manually i.e. with conditions to skip a page when it isn't necessary. That's why I got the warning about using SKIPIF etc. After putting correct names I got some results but not quite good yet. 1) I typed the below {IF {Mergefield Indicatorfieldname} "\" "{Includetext "c:\\path\\page1.doc" ""}{IF {Mergefield Indicatorfieldname} "\" "{Includetext "c:\\path\\page2.doc" ""}{IF {Mergefield Indicatorfieldname} "\" "{Includetext "c:\\path\\page2.doc" ""}etc but only page1 was processed I got the same result when I only typed: {IF {Mergefield Indicatorfieldname} "\" "{Includetext "c:\\path\\page1.doc" ""}} 2) all records in Excel file are processed regardless of value in Excel record (It behaves as if there wasn't the condition "\") Please tell me where is your e-mail address on your web site. I'd like to send you my example and give you my e-mail address and ask you for sending me your sample working document Best regards Tico Użytkownik "Graham Mayor" napisał w wiadomości ... This is complicated enough to explain in English Given that the language problem might then be reversed, I wonder if it would help if you sent me the merge documents so that I can see what you are doing? Zip up the five(?) documents and mail them to the link on my web site. I *may* be able to spot the problem. If you are unable to do that - e-mail me a contact address and I'll send you a sample working document and you can see how it is supposed to work. -- Graham Mayor - Word MVP My web site www.gmayor.com Word MVP web site http://word.mvps.org Tico wrote: Thanks a lot once more. We seem to be talking at cross purposes I am very sorry that my English is so poor. Another problem is that I cannot use English versions of Windows and MS Office so when I want to describe anything I have to translate it into English. From what you have posted earlier, your merge document has five pages (not thousands), some of which will not be required according to the dictates of the data. Right. I'll have thousands of pages as a result of Mailmerge because the Excel file contains thousends (or at least hundreds) of records. You have said that you have a field in the data source which indicates which page will not be required for a given record. Right. Save each of the five pages as a separate document and note the filename and path. Done. Each page contains a table. Besides, fieldnames are rather long so each "source" takes more than 1 page in fact. If it is necessary I could shorten the names of the fields (=names of Excel columns) {IF {Mergefield Indicatorfieldname} "\" "{Includetext "c:\\path\\page1.doc" ""}{IF {Mergefield Indicatorfieldname} "\" "{Includetext "c:\\path\\page2.doc" ""}{IF {Mergefield Indicatorfieldname} "\" "{Includetext "c:\\path\\page2.doc" ""}etc I opened a new Word97 file and then use: Tools MailMerge 1. Create Form Letters Active Window 2. Get Data Open Data Source I opened my Excel file. Then I clicked on the Edit Main Document button. I typed what you wrote using CTRL+F9 (I forgot about it when I tried before). To get Mergefileld Indicatorfieldname I selected it from the Insert Merge Field (left up corner) The paths use double slashes and the names of the files are correct. Afterwards I use: Tools MailMerge 3. Merge button The following options were selected: Merge to a New Document Records to be saved All Without printing empty records Then I clicked on Merge I got the following warning: Microsoft Word You cannot insert the fields DATA, NEXT, NEXTIF or SKIPIF inside other fields (this is my translation) and after clicking on OK I got the following information: MailMerge An error was encountered when counting a value of field in record 1 (this is also my tranaslation) After clicking OK I got just 1 empty page (without inserted values) - the first from 5 pages. Unless the first page of your merge document runs top more than one page, there will only be one page in the merge document - unless the conditions require that the includetext fields include them. I am very sorry but I don't understand it. I suppose it is about what I got but I have language problems with understanding it. Could you please write it more simple, without using the word "unless" which is very difficult to me when I have to understand anything precisely. Sorry. Best regards Tico Użytkownik "Graham Mayor" napisał w wiadomości ... We seem to be talking at cross purposes. From what you have posted earlier, your merge document has five pages (not thousands), some of which will not be required according to the dictates of the data. You have said that you have a field in the data source which indicates which page will not be required for a given record. Save each of the five pages as a separate document and note the filename and path. Then your merge document will contain the conditional fields on the same line eg {IF {Mergefield Indicatorfieldname} "\" "{Includetext "c:\\path\\page1.doc" ""}{IF {Mergefield Indicatorfieldname} "\" "{Includetext "c:\\path\\page2.doc" ""}{IF {Mergefield Indicatorfieldname} "\" "{Includetext "c:\\path\\page2.doc" ""}etc These are fields not simply typed in at the keyboard. Use CTRL+F9 for the brackets, and note that the paths must use double slashes and of course they and the fieldnames must match the actual filenames and fieldnames. Unless the first page of your merge document runs top more than one page, there will only be one page in the merge document - unless the conditions require that the includetext fields include them. When you then merge your database, you will have only the required number of pages for each record. The merge fields in the inserted documents will work as if they were typed on the page. -- Graham Mayor - Word MVP My web site www.gmayor.com Word MVP web site http://word.mvps.org Tico wrote: I read once again your below news and I think that I didn't understand well your advice: "save each page as a separate document" when I tried to use it before. If I have to save each page as a separate document, I'll have to create thousands of files and for each file to include an information about Excel record (number?) in its name. I'm afraid this method would be more complicated and take more time than sorting manually. :-( Regards Tico Użytkownik "Graham Mayor" napisał w wiadomości ... You claim your merge requires a number of pages according to the data. Instead of merging all the pages and deleting the unwanted ones, include only the ones you need according to the requirements of the data ie save each page as a separate document and use includetext to insert only the pages you want. -- Graham Mayor - Word MVP My web site www.gmayor.com Word MVP web site http://word.mvps.org Tico wrote: I am not sure if I understand you well. Do you mean to process for each kind of page separately (as I described in the method with sorting manually) and then to process the MailMerge again just to combine the pages into one file in a proper order? Regards Tico Użytkownik "Graham Mayor" napisał w wiadomości ... From your description you should conditionally insert the pages eg {IF {Mergefield Char} "\" "{IncludeText c:\\path\\page1.doc"}" ""} It is always easier not to add in the pages that you don't need than to remove them later -- Graham Mayor - Word MVP My web site www.gmayor.com Word MVP web site http://word.mvps.org Tico wrote: Sorry, I should have written 5 instead of 3 in my last news. I have 5 kinds of pages however from each record only from 1 to 3 pages can be necessary. In "my" method I "produce" all 5 pages for each Excel record and then I delete unnecessary pages using tha macro from you. Sorting the pages manually I had to repeat the process 5 times however in this case I was able to produce only necessary pages using SKIPIF, of course. But sorting it manually is really a nuisance. I thought about using the "NEXT RECORD IF ..." but in this case I'd have to be able to skip pages in Word. :-( Probably the best way would be to write a "regular" program in Visual Basic or so, but unfortuantely I am not able to. Regards Tico Użytkownik "Tico" napisał w wiadomości ... No because SKIPIF cause to skip a whole record. But I have to "produce" from 1 to 3 possible pages in Word from each record depending on the data in Excel file. That's why I have to "produce" all pages first and then to delete those which are not necessary. I tried to do it another way - I processed the Excel file 3 times and then I sorted the pages manually but in case of big files it is really a nuisance. The order of pages is important. I'll try to solve the problem continuing what I wrote in my prevoius news. I'll try not to center the first line however I don't understand why it worked when I processed it 3 times separately without the extra character. I don't know what causes the difference. Regards Tico Użytkownik "Graham Mayor" napisał w wiadomości ... I am totally bemused now. If you don't want the page(s) with this particular merge record, why are you merging the record in the first place? Wouldn't e.g. {SKIPIF {Mergefield Char} = "\"} work? -- Graham Mayor - Word MVP My web site www.gmayor.com Word MVP web site http://word.mvps.org Tico wrote: The same happens when I put in the Excel file "" instead of " " when I want a page not to be deleted. I think it is somehow connected with the sign of new page because sometimes it is OK but always after another sign of new page. However i don't know how to force a correct sign in the MaiMerge. Regards Tico Użytkownik "Tico" napisał w wiadomości ... I understand. I thought that everything was OK but I have one problem: the additional character damages to keeping a part of the first line in the center. I put in Excel file an addition column and the character "\" is put in it, if the page in Word should be deleted or the character " ", if the page in Word should'n be deleted. What is put : "\" or " " depends on other values in Excel file. Everything is OK but the first line on pages with " " is moved much more to the left than the 1 character (" ") should use (the same happens to pages with "\" but it is not important as they are deleted afterwards). The first line on each page consists of the constant text and a number that is put during the MailMerge process, like this ABCDEF GHIJ KLMNOP {MERGEFIELD No} The text should be in the center of the page, and the No on the right side. After I added the character it looks like this: {MERGEFIELD Char}ABCDEF GHIJ KLMNOP {MERGEFIELD No} (Before I put the additional character everything was OK and the constant text was in the center) My MailMerge "source" file consist of 5 pages, not just one. After the process of MailMerging I delete the "extra" pages using the macro from you. Each of the "source" 5 pages has similar first line as I described above. Could you help me once more, please? Regards Tico Użytkownik "Graham Mayor" napisał w wiadomości ... Page is a vague concept in Word which is not a page layout application and if you remove pages the document reflows to create a new 'page' structure. -- Graham Mayor - Word MVP My web site www.gmayor.com Word MVP web site http://word.mvps.org Tico wrote: Thank you both very, very much once again. I used the macro to the big MailMerge output file and it works perfectly. The macro would work faster if it could test just the first character on each page but I don't know how to change it. But it works very well and I am very grateful. As for a tutorial I expected something I had when I learnt other languages which began with "Hello World" or something like this. Then, step by step, it showed how to use more and more complicated language tools. Regards Tico Użytkownik "Graham Mayor" napisał w wiadomości ... If you are splitting the results of a mail merge, see http://www.gmayor.com/individual_merge_letters.htm As Doug says, the only way to learn vba is to put it to use to perform simple tasks and then get more adventurous. You can always use the macro recorder to give you some ideas. It is by no means perfect but it does help get you started. You will find lots of coding examples in the vba programming forums and on various web site, including my own. The vba help in Word 2007 is rather better than in earlier versions. -- Graham Mayor - Word MVP My web site www.gmayor.com Word MVP web site http://word.mvps.org Tico wrote: Thank you very, very much. I created a sample file and it works! Now I have to put the macro into my big file which is a result of MailMerge and make a lot of tests. By the way, I know almost nothing about VBA for Word. I looked at your page and I found a lot of interesting things there. However what I need most at the moment is any tutorial how to create simple macros in Word from the very beginning. Not just examples, which are important too, but first of all the most basic rules. I read that one of ways is to record macros using Word and then to analyse it in VBA Editor. I think that this can be useful later, when you know a lot, but not at the beginning. I am looking for any lessons, step by step showing what is neccessary in a macro and what it means. Then more and more functions to write working macros. Having such background I'll be able to learn using other methods. I tried to find anything like this in the Internet to download or use on line, but without any success. I found a lot for Excel but I read that the rules are not the same. Could you please advice me anything suitable for a person who is just starting with writing macros for Word? Thanks again for your help. Regards Tico Użytkownik "Graham Mayor" napisał w wiadomości ... The lines indicated in red have wrapped prematurely use the following which should not wrap Sub DeleteMarkedPages() Selection.HomeKey wdStory Selection.Find.ClearFormatting With Selection.Find Do While .Execute(findText:="\", _ MatchWildcards:=False, _ Wrap:=wdFindContinue, _ Forward:=True) = True Selection.Bookmarks("\page").Range.Delete Loop End With http://www.gmayor.com/installing_macro.htm The macro will remove any page with the \ character in Word 2007 and should work in Word 97 also, though I don't have it available to check. Word 2007 will open a Word document from Word 97 without the need to 'convert' it. -- Graham Mayor - Word MVP My web site www.gmayor.com Word MVP web site http://word.mvps.org Tico wrote: Thank you very much for your prompt reply. Unfortunately I don't know enough about macros to be able to use the macro. When I tried to use it I got the following lines in red: Do While .Execute(FindText:="#*#", MatchWildcards:=False, Wrap:=wdFindContinue, Forward:=True) = True Selection.Bookmarks("\page").Range.Delete regardless what I replaced the "#*#" with. My special character is \. I don't even know what I should writei n the macro: "#\#", "\" or simply \ I haven't found FindText in the "VBA for Dummies" for Office 97 that I have so I think I should save my file as Word 2007 first and then use the macro. I have Office 2007 (home edition) but I am not familiar with it yet, at least not to use macros. I am afraid I'll have to remove the pages manually. :-( Regards Tico Użytkownik "Doug Robbins - Word MVP" napisał w wiadomości ... Use a macro containing the following code where you replace the #*# with the special character that you intend to use. Selection.HomeKey wdStory Selection.Find.ClearFormatting With Selection.Find Do While .Execute(FindText:="#*#", MatchWildcards:=False, Wrap:=wdFindContinue, Forward:=True) = True Selection.Bookmarks("\page").Range.Delete Loop End With -- 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 "Tico" wrote in message ... Hi All, I have a big MS Word 97 file. I am looking for any method that let me remove automatically some pages which I can mark using, for example, a special character as the first on each page or in any other way. I would be also satisfied if I could automatically skip the pages whilst printing the file. I can use the MS Word 2007 to do it, if necessary. Could anyone help me please? The matter is urgent.:-) Regards Tico |
#29
Posted to microsoft.public.word.newusers
|
|||
|
|||
How to remove automatically some pages?
Tico wrote:
I still can't see it there. Sorry. Click the waving note near the bottom of the Home page. I used the .doc from you and I replaced the spaces in the field names with underscores. At the moment all 5 pages are processed but the condition "\" is still not checked so I get 40 pages as result (8 records in my example by 5 pages). I'm not having the best of days There was an error in my syntax that wouldn't have helped . It should have read: { IF { MERGEFIELD I } "\" "{ Includetext "c:\\test\\Sz_I.doc" \* MERGEFORMAT }" ""}{ IF { MERGEFIELD II_bez } "\" "{ Includetext "c:\\test\\Sz_II.doc" \* MERGEFORMAT }" "" }{ IF { MERGEFIELD II_str } "\" "{ Includetext "c:\\test\\Sz_II_s.doc" \* MERGEFORMAT } " "" }{ IF { MERGEFIELD III_bez } "\" "{ Includetext "c:\\test\\Sz_III.doc" \* MERGEFORMAT }" "" }{ IF { MERGEFIELD III_str } "\" "{ Includetext "c:\\test\\Sz_III_s.doc" \* MERGEFORMAT }" ""} There appears to be an issue with the slash character '\' that you have used in the test fields. I would suggest replacing that with '1' or 'A' and changing the conditional fields accordingly. The other problems may relate to the fact that you are working in a different language which I don't understand and which I cannot entirely reproduce here so I regret I am unable to help you further to get this to produce exactly what you want. -- Graham Mayor - Word MVP My web site www.gmayor.com Word MVP web site http://word.mvps.org |
#30
Posted to microsoft.public.word.newusers
|
|||
|
|||
How to remove automatically some pages?
I still can't see it there. Sorry.
Click the waving note near the bottom of the Home page. Oh yes. I can see it now.. Sorry, I treated the waving element as a picture. :-) { IF { MERGEFIELD I } "\" "{ Includetext "c:\\test\\Sz_I.doc" \* MERGEFORMAT }" ""}{ IF { MERGEFIELD II_bez } "\" "{ Includetext "c:\\test\\Sz_II.doc" \* MERGEFORMAT }" "" }{ IF { MERGEFIELD II_str } "\" "{ Includetext "c:\\test\\Sz_II_s.doc" \* MERGEFORMAT } " "" }{ IF { MERGEFIELD III_bez } "\" "{ Includetext "c:\\test\\Sz_III.doc" \* MERGEFORMAT }" "" }{ IF { MERGEFIELD III_str } "\" "{ Includetext "c:\\test\\Sz_III_s.doc" \* MERGEFORMAT }" ""} OK. I'll try in a moment. There appears to be an issue with the slash character '\' that you have used in the test fields. I would suggest replacing that with '1' or 'A' and changing the conditional fields accordingly. I thought about it. As you know I wanted to remove pages with any special character so I chose "\" because it was not used in the data. Now I can change it. The other problems may relate to the fact that you are working in a different language which I don't understand and which I cannot entirely reproduce here so I regret I am unable to help you further to get this to produce exactly what you want. I realise that. I'll try to get correct results on my own. You mentioned that you could send me your sample working document. If you did, I'd be happy. :-) Thank you very, very much for all your help. I learnt a lot from you. :-) Best regards Tico Użytkownik "Graham Mayor" napisał w wiadomości ... Tico wrote: I still can't see it there. Sorry. Click the waving note near the bottom of the Home page. I used the .doc from you and I replaced the spaces in the field names with underscores. At the moment all 5 pages are processed but the condition "\" is still not checked so I get 40 pages as result (8 records in my example by 5 pages). I'm not having the best of days There was an error in my syntax that wouldn't have helped . It should have read: { IF { MERGEFIELD I } "\" "{ Includetext "c:\\test\\Sz_I.doc" \* MERGEFORMAT }" ""}{ IF { MERGEFIELD II_bez } "\" "{ Includetext "c:\\test\\Sz_II.doc" \* MERGEFORMAT }" "" }{ IF { MERGEFIELD II_str } "\" "{ Includetext "c:\\test\\Sz_II_s.doc" \* MERGEFORMAT } " "" }{ IF { MERGEFIELD III_bez } "\" "{ Includetext "c:\\test\\Sz_III.doc" \* MERGEFORMAT }" "" }{ IF { MERGEFIELD III_str } "\" "{ Includetext "c:\\test\\Sz_III_s.doc" \* MERGEFORMAT }" ""} There appears to be an issue with the slash character '\' that you have used in the test fields. I would suggest replacing that with '1' or 'A' and changing the conditional fields accordingly. The other problems may relate to the fact that you are working in a different language which I don't understand and which I cannot entirely reproduce here so I regret I am unable to help you further to get this to produce exactly what you want. -- Graham Mayor - Word MVP My web site www.gmayor.com Word MVP web site http://word.mvps.org |
#31
Posted to microsoft.public.word.newusers
|
|||
|
|||
How to remove automatically some pages?
I have sent you a sample document as requested.
-- Graham Mayor - Word MVP My web site www.gmayor.com Word MVP web site http://word.mvps.org Tico wrote: I still can't see it there. Sorry. Click the waving note near the bottom of the Home page. Oh yes. I can see it now.. Sorry, I treated the waving element as a picture. :-) { IF { MERGEFIELD I } "\" "{ Includetext "c:\\test\\Sz_I.doc" \* MERGEFORMAT }" ""}{ IF { MERGEFIELD II_bez } "\" "{ Includetext "c:\\test\\Sz_II.doc" \* MERGEFORMAT }" "" }{ IF { MERGEFIELD II_str } "\" "{ Includetext "c:\\test\\Sz_II_s.doc" \* MERGEFORMAT } " "" }{ IF { MERGEFIELD III_bez } "\" "{ Includetext "c:\\test\\Sz_III.doc" \* MERGEFORMAT }" "" }{ IF { MERGEFIELD III_str } "\" "{ Includetext "c:\\test\\Sz_III_s.doc" \* MERGEFORMAT }" ""} OK. I'll try in a moment. There appears to be an issue with the slash character '\' that you have used in the test fields. I would suggest replacing that with '1' or 'A' and changing the conditional fields accordingly. I thought about it. As you know I wanted to remove pages with any special character so I chose "\" because it was not used in the data. Now I can change it. The other problems may relate to the fact that you are working in a different language which I don't understand and which I cannot entirely reproduce here so I regret I am unable to help you further to get this to produce exactly what you want. I realise that. I'll try to get correct results on my own. You mentioned that you could send me your sample working document. If you did, I'd be happy. :-) Thank you very, very much for all your help. I learnt a lot from you. :-) Best regards Tico Użytkownik "Graham Mayor" napisał w wiadomości ... Tico wrote: I still can't see it there. Sorry. Click the waving note near the bottom of the Home page. I used the .doc from you and I replaced the spaces in the field names with underscores. At the moment all 5 pages are processed but the condition "\" is still not checked so I get 40 pages as result (8 records in my example by 5 pages). I'm not having the best of days There was an error in my syntax that wouldn't have helped . It should have read: { IF { MERGEFIELD I } "\" "{ Includetext "c:\\test\\Sz_I.doc" \* MERGEFORMAT }" ""}{ IF { MERGEFIELD II_bez } "\" "{ Includetext "c:\\test\\Sz_II.doc" \* MERGEFORMAT }" "" }{ IF { MERGEFIELD II_str } "\" "{ Includetext "c:\\test\\Sz_II_s.doc" \* MERGEFORMAT } " "" }{ IF { MERGEFIELD III_bez } "\" "{ Includetext "c:\\test\\Sz_III.doc" \* MERGEFORMAT }" "" }{ IF { MERGEFIELD III_str } "\" "{ Includetext "c:\\test\\Sz_III_s.doc" \* MERGEFORMAT }" ""} There appears to be an issue with the slash character '\' that you have used in the test fields. I would suggest replacing that with '1' or 'A' and changing the conditional fields accordingly. The other problems may relate to the fact that you are working in a different language which I don't understand and which I cannot entirely reproduce here so I regret I am unable to help you further to get this to produce exactly what you want. -- Graham Mayor - Word MVP My web site www.gmayor.com Word MVP web site http://word.mvps.org |
#32
Posted to microsoft.public.word.newusers
|
|||
|
|||
How to remove automatically some pages?
I have got it. :-) Thank you very, very much.
Best regards Tico Użytkownik "Graham Mayor" napisał w wiadomości ... I have sent you a sample document as requested. -- Graham Mayor - Word MVP My web site www.gmayor.com Word MVP web site http://word.mvps.org Tico wrote: I still can't see it there. Sorry. Click the waving note near the bottom of the Home page. Oh yes. I can see it now.. Sorry, I treated the waving element as a picture. :-) { IF { MERGEFIELD I } "\" "{ Includetext "c:\\test\\Sz_I.doc" \* MERGEFORMAT }" ""}{ IF { MERGEFIELD II_bez } "\" "{ Includetext "c:\\test\\Sz_II.doc" \* MERGEFORMAT }" "" }{ IF { MERGEFIELD II_str } "\" "{ Includetext "c:\\test\\Sz_II_s.doc" \* MERGEFORMAT } " "" }{ IF { MERGEFIELD III_bez } "\" "{ Includetext "c:\\test\\Sz_III.doc" \* MERGEFORMAT }" "" }{ IF { MERGEFIELD III_str } "\" "{ Includetext "c:\\test\\Sz_III_s.doc" \* MERGEFORMAT }" ""} OK. I'll try in a moment. There appears to be an issue with the slash character '\' that you have used in the test fields. I would suggest replacing that with '1' or 'A' and changing the conditional fields accordingly. I thought about it. As you know I wanted to remove pages with any special character so I chose "\" because it was not used in the data. Now I can change it. The other problems may relate to the fact that you are working in a different language which I don't understand and which I cannot entirely reproduce here so I regret I am unable to help you further to get this to produce exactly what you want. I realise that. I'll try to get correct results on my own. You mentioned that you could send me your sample working document. If you did, I'd be happy. :-) Thank you very, very much for all your help. I learnt a lot from you. :-) Best regards Tico Użytkownik "Graham Mayor" napisał w wiadomości ... Tico wrote: I still can't see it there. Sorry. Click the waving note near the bottom of the Home page. I used the .doc from you and I replaced the spaces in the field names with underscores. At the moment all 5 pages are processed but the condition "\" is still not checked so I get 40 pages as result (8 records in my example by 5 pages). I'm not having the best of days There was an error in my syntax that wouldn't have helped . It should have read: { IF { MERGEFIELD I } "\" "{ Includetext "c:\\test\\Sz_I.doc" \* MERGEFORMAT }" ""}{ IF { MERGEFIELD II_bez } "\" "{ Includetext "c:\\test\\Sz_II.doc" \* MERGEFORMAT }" "" }{ IF { MERGEFIELD II_str } "\" "{ Includetext "c:\\test\\Sz_II_s.doc" \* MERGEFORMAT } " "" }{ IF { MERGEFIELD III_bez } "\" "{ Includetext "c:\\test\\Sz_III.doc" \* MERGEFORMAT }" "" }{ IF { MERGEFIELD III_str } "\" "{ Includetext "c:\\test\\Sz_III_s.doc" \* MERGEFORMAT }" ""} There appears to be an issue with the slash character '\' that you have used in the test fields. I would suggest replacing that with '1' or 'A' and changing the conditional fields accordingly. The other problems may relate to the fact that you are working in a different language which I don't understand and which I cannot entirely reproduce here so I regret I am unable to help you further to get this to produce exactly what you want. -- Graham Mayor - Word MVP My web site www.gmayor.com Word MVP web site http://word.mvps.org |
#33
Posted to microsoft.public.word.newusers
|
|||
|
|||
How to remove automatically some pages?
You are welcome
-- Graham Mayor - Word MVP My web site www.gmayor.com Word MVP web site http://word.mvps.org Tico wrote: I have got it. :-) Thank you very, very much. Best regards Tico Użytkownik "Graham Mayor" napisał w wiadomości ... I have sent you a sample document as requested. -- Graham Mayor - Word MVP My web site www.gmayor.com Word MVP web site http://word.mvps.org Tico wrote: I still can't see it there. Sorry. Click the waving note near the bottom of the Home page. Oh yes. I can see it now.. Sorry, I treated the waving element as a picture. :-) { IF { MERGEFIELD I } "\" "{ Includetext "c:\\test\\Sz_I.doc" \* MERGEFORMAT }" ""}{ IF { MERGEFIELD II_bez } "\" "{ Includetext "c:\\test\\Sz_II.doc" \* MERGEFORMAT }" "" }{ IF { MERGEFIELD II_str } "\" "{ Includetext "c:\\test\\Sz_II_s.doc" \* MERGEFORMAT } " "" }{ IF { MERGEFIELD III_bez } "\" "{ Includetext "c:\\test\\Sz_III.doc" \* MERGEFORMAT }" "" }{ IF { MERGEFIELD III_str } "\" "{ Includetext "c:\\test\\Sz_III_s.doc" \* MERGEFORMAT }" ""} OK. I'll try in a moment. There appears to be an issue with the slash character '\' that you have used in the test fields. I would suggest replacing that with '1' or 'A' and changing the conditional fields accordingly. I thought about it. As you know I wanted to remove pages with any special character so I chose "\" because it was not used in the data. Now I can change it. The other problems may relate to the fact that you are working in a different language which I don't understand and which I cannot entirely reproduce here so I regret I am unable to help you further to get this to produce exactly what you want. I realise that. I'll try to get correct results on my own. You mentioned that you could send me your sample working document. If you did, I'd be happy. :-) Thank you very, very much for all your help. I learnt a lot from you. :-) Best regards Tico Użytkownik "Graham Mayor" napisał w wiadomości ... Tico wrote: I still can't see it there. Sorry. Click the waving note near the bottom of the Home page. I used the .doc from you and I replaced the spaces in the field names with underscores. At the moment all 5 pages are processed but the condition "\" is still not checked so I get 40 pages as result (8 records in my example by 5 pages). I'm not having the best of days There was an error in my syntax that wouldn't have helped . It should have read: { IF { MERGEFIELD I } "\" "{ Includetext "c:\\test\\Sz_I.doc" \* MERGEFORMAT }" ""}{ IF { MERGEFIELD II_bez } "\" "{ Includetext "c:\\test\\Sz_II.doc" \* MERGEFORMAT }" "" }{ IF { MERGEFIELD II_str } "\" "{ Includetext "c:\\test\\Sz_II_s.doc" \* MERGEFORMAT } " "" }{ IF { MERGEFIELD III_bez } "\" "{ Includetext "c:\\test\\Sz_III.doc" \* MERGEFORMAT }" "" }{ IF { MERGEFIELD III_str } "\" "{ Includetext "c:\\test\\Sz_III_s.doc" \* MERGEFORMAT }" ""} There appears to be an issue with the slash character '\' that you have used in the test fields. I would suggest replacing that with '1' or 'A' and changing the conditional fields accordingly. The other problems may relate to the fact that you are working in a different language which I don't understand and which I cannot entirely reproduce here so I regret I am unable to help you further to get this to produce exactly what you want. -- Graham Mayor - Word MVP My web site www.gmayor.com Word MVP web site http://word.mvps.org |
Reply |
Thread Tools | |
Display Modes | |
|
|
Similar Threads | ||||
Thread | Forum | |||
When adding pages , can reference to pages change automatically? | Microsoft Word Help | |||
How to remove hyperlinks automatically by default? | Microsoft Word Help | |||
The document is not automatically adjusting to remove blank pages | Tables | |||
Remove/convert nested subtables automatically | Tables | |||
Automatically remove hyperlinks in word | Microsoft Word Help |