Microsoft Office Forums

Go Back   Microsoft Office Forums > >

Reply
 
Thread Tools Display Modes
  #1  
Old 12-31-2020, 06:55 PM
Lefemmenikita Lefemmenikita is offline Deleting specific pages from Word with VBA Windows 10 Deleting specific pages from Word with VBA Office 2013
Novice
Deleting specific pages from Word with VBA
 
Join Date: Dec 2020
Posts: 4
Lefemmenikita is on a distinguished road
Default 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
Reply With Quote
  #2  
Old 12-31-2020, 09:46 PM
gmayor's Avatar
gmayor gmayor is offline Deleting specific pages from Word with VBA Windows 10 Deleting specific pages from Word with VBA Office 2016
Expert
 
Join Date: Aug 2014
Posts: 3,344
gmayor is a name known to allgmayor is a name known to allgmayor is a name known to allgmayor is a name known to allgmayor is a name known to allgmayor is a name known to all
Default

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
Reply With Quote
  #3  
Old 01-01-2021, 04:56 PM
Lefemmenikita Lefemmenikita is offline Deleting specific pages from Word with VBA Windows 10 Deleting specific pages from Word with VBA Office 2013
Novice
Deleting specific pages from Word with VBA
 
Join Date: Dec 2020
Posts: 4
Lefemmenikita is on a distinguished road
Default

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
Reply With Quote
  #4  
Old 01-01-2021, 07:01 PM
Charles Kenyon Charles Kenyon is offline Deleting specific pages from Word with VBA Windows 10 Deleting specific pages from Word with VBA Office 2019
Moderator
 
Join Date: Mar 2012
Location: Sun Prairie, Wisconsin
Posts: 7,103
Charles Kenyon is a splendid one to beholdCharles Kenyon is a splendid one to beholdCharles Kenyon is a splendid one to beholdCharles Kenyon is a splendid one to beholdCharles Kenyon is a splendid one to beholdCharles Kenyon is a splendid one to beholdCharles Kenyon is a splendid one to beholdCharles Kenyon is a splendid one to behold
Default

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.
Reply With Quote
  #5  
Old 01-01-2021, 10:28 PM
Lefemmenikita Lefemmenikita is offline Deleting specific pages from Word with VBA Windows 10 Deleting specific pages from Word with VBA Office 2013
Novice
Deleting specific pages from Word with VBA
 
Join Date: Dec 2020
Posts: 4
Lefemmenikita is on a distinguished road
Default

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
Reply With Quote
  #6  
Old 01-01-2021, 11:16 PM
Charles Kenyon Charles Kenyon is offline Deleting specific pages from Word with VBA Windows 10 Deleting specific pages from Word with VBA Office 2019
Moderator
 
Join Date: Mar 2012
Location: Sun Prairie, Wisconsin
Posts: 7,103
Charles Kenyon is a splendid one to beholdCharles Kenyon is a splendid one to beholdCharles Kenyon is a splendid one to beholdCharles Kenyon is a splendid one to beholdCharles Kenyon is a splendid one to beholdCharles Kenyon is a splendid one to beholdCharles Kenyon is a splendid one to beholdCharles Kenyon is a splendid one to behold
Default

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.
Reply With Quote
  #7  
Old 01-01-2021, 11:32 PM
Lefemmenikita Lefemmenikita is offline Deleting specific pages from Word with VBA Windows 10 Deleting specific pages from Word with VBA Office 2013
Novice
Deleting specific pages from Word with VBA
 
Join Date: Dec 2020
Posts: 4
Lefemmenikita is on a distinguished road
Default

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
Reply With Quote
  #8  
Old 01-02-2021, 01:01 PM
Charles Kenyon Charles Kenyon is offline Deleting specific pages from Word with VBA Windows 10 Deleting specific pages from Word with VBA Office 2019
Moderator
 
Join Date: Mar 2012
Location: Sun Prairie, Wisconsin
Posts: 7,103
Charles Kenyon is a splendid one to beholdCharles Kenyon is a splendid one to beholdCharles Kenyon is a splendid one to beholdCharles Kenyon is a splendid one to beholdCharles Kenyon is a splendid one to beholdCharles Kenyon is a splendid one to beholdCharles Kenyon is a splendid one to beholdCharles Kenyon is a splendid one to behold
Default

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.
Reply With Quote
  #9  
Old 01-04-2021, 12:29 AM
macropod's Avatar
macropod macropod is offline Deleting specific pages from Word with VBA Windows 10 Deleting specific pages from Word with VBA Office 2016
Administrator
 
Join Date: Dec 2010
Location: Canberra, Australia
Posts: 20,726
macropod has a brilliant futuremacropod has a brilliant futuremacropod has a brilliant futuremacropod has a brilliant futuremacropod has a brilliant futuremacropod has a brilliant futuremacropod has a brilliant futuremacropod has a brilliant futuremacropod has a brilliant futuremacropod has a brilliant futuremacropod has a brilliant future
Default

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]
Reply With Quote
Reply

Tags
blank pages, vba

Thread Tools
Display Modes


Similar Threads
Thread Thread Starter Forum Replies Last Post
Deleting specific pages from Word with VBA 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 specific pages from Word with VBA Deleting A blank Line that has a specific heading style , word 2010 & 2013 SteveWcg Word 5 01-08-2014 10:37 PM
Deleting specific pages from Word with VBA deleting pages paul_pearson Word 4 03-22-2013 12:18 AM
Deleting specific pages from Word with VBA Deleting blank pages Microsoftenquirer1000 Word 14 08-27-2012 01:24 PM

Other Forums: Access Forums - Senior Forums

All times are GMT -7. The time now is 06:46 AM.


Powered by vBulletin® Version 3.8.11
Copyright ©2000 - 2021, vBulletin Solutions Inc.
Search Engine Optimisation provided by DragonByte SEO (Lite) - vBulletin Mods & Addons Copyright © 2021 DragonByte Technologies Ltd.
MSOfficeForums.com is not affiliated with Microsoft