#1
|
|||
|
|||
Deleting specific pages from Word with VBA
Hi there
I had a question related to an existing old thread here: https://www.msofficeforums.com/word-...-document.html I have a word document that has blank pages in between the document as a result of continuous section breaks. I have found the macro linked above correctly identifies the pages which need to be deleted. How do I modify the macro so that rather than it outputting what the blank pages are in a message box, it actually deletes the pages instead? Thanks |
#2
|
||||
|
||||
Does this relate to your post at Adding headers and footers to all sections of word doc and deleting blank sections
__________________
Graham Mayor - MS MVP (Word) (2002-2019) Visit my web site for more programming tips and ready made processes www.gmayor.com |
#3
|
|||
|
|||
Hi. Yes, it is related.
I posted a separate thread here though since I was wanting to modify the macro linked here as a stand alone macro as well as to facilitate what I am trying to do with the splitting a large file into multiple files in the other post thanks |
#4
|
|||
|
|||
Keep is mind that Word does not really think in terms of pages. What you are trying to do is change or eliminate section breaks.
Word Doesn't Know What a Page Is If your two posts are related, you should at least look at: Excelguru Help Site - A message to forum cross posters. |
#5
|
|||
|
|||
Thanks. I wasn't sure if this counted as cross posting initially though I will keep that in mind in future.
The original macro does correctly identify the 'blank pages' (in this case, page 1,5) What I was hoping to do is tweak the code so that rather than it stating what the blank pages are in a message box, it deletes them instead. since the numbers returned "1,5" are stored as a string in the vba code, how do I store these variables as pagenumbers instead? thanks |
#6
|
|||
|
|||
Did you read Daiya Mitchell's article on Word pages (previous link)? You need to address the section breaks, not the pages.
This is a lot of work for two pages. Last edited by Charles Kenyon; 01-02-2021 at 01:08 PM. |
#7
|
|||
|
|||
Sorry, yes i read it..
I was using the 'page' to refer to section break interchangeably sorry. Is there any vba code to delete 'blank' sections in that case? The documents will be of varying lengths (in terms of number of invoices and accordingly, section breaks) which is why I am reluctant to delete blank sections mainly Thanks |
#8
|
|||
|
|||
They will not necessarily be blank sections but rather section breaks that generate a blank page.
A section break controls lots of formatting in the section before the break. An odd-page or even-page or next-page section break will give you a new page. The even-page and odd-page breaks may generate a blank page. When to use Section breaks in Microsoft Word How are you producing these invoices that they have these section breaks? Mail merge? If so, look to your primary merge document. Something other than section breaks may also be causing blank pages. See Deleting “Blank” Pages by Suzanne Barnhill, MVP. I am not going to attempt to write a macro on this. I think it is beyond my comfort level. However, to have such a macro, you need to analyze your situation and what it is you need the macro to do for you. This analysis needs to be in terms of the document structure rather than what it is you are seeing. A macro can only work with the Word's understanding of what is in the document. |
#9
|
||||
|
||||
To see what's involved in deleting Sections, take a look at: https://www.msofficeforums.com/20227-post6.html.
As implied by Charles said, it would be much better to address the problem at its source.
__________________
Cheers, Paul Edstein [Fmr MS MVP - Word] |
Tags |
blank pages, vba |
|
Similar Threads | ||||
Thread | Thread Starter | Forum | Replies | Last Post |
Deleting Characters in a specific location in Word 2010 | ppayaw | Word VBA | 8 | 12-13-2016 08:11 AM |
Copying specific columns of a table to WORD and deleting rows | ffinley | Word VBA | 5 | 12-07-2015 04:01 PM |
Deleting A blank Line that has a specific heading style , word 2010 & 2013 | SteveWcg | Word | 5 | 01-08-2014 10:37 PM |
deleting pages | paul_pearson | Word | 4 | 03-22-2013 12:18 AM |
Deleting blank pages | Microsoftenquirer1000 | Word | 14 | 08-27-2012 01:24 PM |