Microsoft Office Forums

Go Back   Microsoft Office Forums > >

Reply
 
Thread Tools Display Modes
  #1  
Old 09-06-2014, 05:16 AM
Dimsok Dimsok is offline Delete blank pages Windows XP Delete blank pages Office 2007
Advanced Beginner
Delete blank pages
 
Join Date: Sep 2014
Location: exUSSR
Posts: 50
Dimsok is on a distinguished road
Default Delete blank pages

Is there a way to delete blank pages in the end of document? I did try that:

Public Sub DeleteBlankPage()

Selection.GoTo What:=wdGoToBookmark, Name:="\page"

If isBlankSelection Then

Selection.Delete

End If

End Sub



Public Function BlankPageSelection()

For Each c In Selection.Characters

If (c <> vbCr And c <> vbTab And c <> vbFormFeed And c <> " ") Then

BlankPageSelection = False

Exit Function

End If

Next

BlankPageSelection = True

End Function


Read more :

but no sucess
Reply With Quote
  #2  
Old 09-06-2014, 06:17 AM
gmayor's Avatar
gmayor gmayor is offline Delete blank pages Windows 7 64bit Delete blank pages Office 2010 32bit
Expert
 
Join Date: Aug 2014
Posts: 4,101
gmayor has much to be proud ofgmayor has much to be proud ofgmayor has much to be proud ofgmayor has much to be proud ofgmayor has much to be proud ofgmayor has much to be proud ofgmayor has much to be proud ofgmayor has much to be proud of
Default

It would help to know why there is a blank page (or pages). Use the ¶ button on the Home tab to establish why there are blank pages, so the cause can be addressed.
__________________
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 09-06-2014, 06:30 AM
Dimsok Dimsok is offline Delete blank pages Windows XP Delete blank pages Office 2007
Advanced Beginner
Delete blank pages
 
Join Date: Sep 2014
Location: exUSSR
Posts: 50
Dimsok is on a distinguished road
Default

I know that it cause of hidden symbols, I know that i can delete them manually, but maybe it's possible to delete them with macros. When i type, blank pages always appear after about 30 pages. So in document with about 300 pages i have plenty of them
Reply With Quote
  #4  
Old 09-06-2014, 11:15 PM
gmayor's Avatar
gmayor gmayor is offline Delete blank pages Windows 7 64bit Delete blank pages Office 2010 32bit
Expert
 
Join Date: Aug 2014
Posts: 4,101
gmayor has much to be proud ofgmayor has much to be proud ofgmayor has much to be proud ofgmayor has much to be proud ofgmayor has much to be proud ofgmayor has much to be proud ofgmayor has much to be proud ofgmayor has much to be proud of
Default

It may be possible, but until you tell us what hidden symbols are involved, we cannot progress further with this. Maybe the following macro will help identify them. Select the character and run the macro.

Code:
Sub AnsiCode()
Dim myData As DataObject
Dim vChar As Variant
Dim sCode As String
    Set myData = New DataObject
    For Each vChar In Selection.Characters
        sCode = sCode & "ChrW(" & AscW(vChar) & ") & "
    Next
    sCode = Left(sCode, Len(sCode) - 3)
    MsgBox sCode & vbCr & vbCr & "Copied to clipboard!"
    myData.SetText sCode
    myData.PutInClipboard
End Sub
__________________
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
  #5  
Old 09-07-2014, 01:56 AM
Dimsok Dimsok is offline Delete blank pages Windows XP Delete blank pages Office 2007
Advanced Beginner
Delete blank pages
 
Join Date: Sep 2014
Location: exUSSR
Posts: 50
Dimsok is on a distinguished road
Default

Quote:
Originally Posted by gmayor View Post
It may be possible, but until you tell us what hidden symbols are involved, we cannot progress further with this. Maybe the following macro will help identify them. Select the character and run the macro.

Code:
Sub AnsiCode()
Dim myData As DataObject
Dim vChar As Variant
Dim sCode As String
    Set myData = New DataObject
    For Each vChar In Selection.Characters
        sCode = sCode & "ChrW(" & AscW(vChar) & ") & "
    Next
    sCode = Left(sCode, Len(sCode) - 3)
    MsgBox sCode & vbCr & vbCr & "Copied to clipboard!"
    myData.SetText sCode
    myData.PutInClipboard
End Sub
Compile error. User defined type not defined.

What hidden symbiols? Just ¶¶¶. Is that possible to delete them in the end of document in one click?
Reply With Quote
  #6  
Old 09-07-2014, 02:37 AM
gmayor's Avatar
gmayor gmayor is offline Delete blank pages Windows 7 64bit Delete blank pages Office 2010 32bit
Expert
 
Join Date: Aug 2014
Posts: 4,101
gmayor has much to be proud ofgmayor has much to be proud ofgmayor has much to be proud ofgmayor has much to be proud ofgmayor has much to be proud ofgmayor has much to be proud ofgmayor has much to be proud ofgmayor has much to be proud of
Default

If they are just paragraph breaks at the end then

Code:
Sub Macro1()
Dim i As Long
    For i = ActiveDocument.Paragraphs.Count To 1 Step -1
        If Len(ActiveDocument.Paragraphs(i).Range) = 1 Then
            ActiveDocument.Paragraphs(i).Range.Delete
        Else
            Exit For
        End If
    Next i
End Sub
As for the compiler error with the previous macro, you have a missing object library reference - Microsoft Forms 2.0

If you change
Dim dFname As DataObject
to
Dim dFname As Object

it should compile.
__________________
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
  #7  
Old 09-07-2014, 04:03 AM
macropod's Avatar
macropod macropod is offline Delete blank pages Windows 7 64bit Delete blank pages Office 2010 32bit
Administrator
 
Join Date: Dec 2010
Location: Canberra, Australia
Posts: 21,956
macropod has a reputation beyond reputemacropod has a reputation beyond reputemacropod has a reputation beyond reputemacropod has a reputation beyond reputemacropod has a reputation beyond reputemacropod has a reputation beyond reputemacropod has a reputation beyond reputemacropod has a reputation beyond reputemacropod has a reputation beyond reputemacropod has a reputation beyond reputemacropod has a reputation beyond repute
Default

Quote:
Originally Posted by Dimsok View Post
When i type, blank pages always appear after about 30 pages. So in document with about 300 pages i have plenty of them
That suggests you're going about the blank page creation the wrong way. Are you using manual page breaks or Section Breaks to create them, or some other method?

Here's a slightly different approach to clearing out trailing content in a document:
Code:
Sub Demo()
With ActiveDocument.Characters.Last
  While .Previous.Text Like "[ " & Chr(160) & vbCr & vbTab & Chr(12) & "]"
    .Previous.Text = vbNullString
  Wend
End With
End Sub
__________________
Cheers,
Paul Edstein
[Fmr MS MVP - Word]
Reply With Quote
  #8  
Old 09-07-2014, 05:04 AM
Dimsok Dimsok is offline Delete blank pages Windows XP Delete blank pages Office 2007
Advanced Beginner
Delete blank pages
 
Join Date: Sep 2014
Location: exUSSR
Posts: 50
Dimsok is on a distinguished road
Default

Quote:
Originally Posted by macropod View Post
Are you using manual page breaks or Section Breaks to create them, or some other method?
[/code]
I don't have any guess. Just in default. Office 2007.
Reply With Quote
  #9  
Old 09-07-2014, 07:44 AM
Dimsok Dimsok is offline Delete blank pages Windows XP Delete blank pages Office 2007
Advanced Beginner
Delete blank pages
 
Join Date: Sep 2014
Location: exUSSR
Posts: 50
Dimsok is on a distinguished road
Default

Thanks for the codes. That is what i was looking for
Reply With Quote
  #10  
Old 10-30-2014, 04:58 AM
tejaspareek tejaspareek is offline Delete blank pages Windows 7 64bit Delete blank pages Office 2010 64bit
Novice
 
Join Date: Oct 2014
Posts: 13
tejaspareek is on a distinguished road
Default

Hello Maropod,

Thank you for the code; the code works when we have to delete blank pages from the end of the document but is not working for the pages in between
Reply With Quote
  #11  
Old 10-30-2014, 05:12 AM
macropod's Avatar
macropod macropod is offline Delete blank pages Windows 7 64bit Delete blank pages Office 2010 32bit
Administrator
 
Join Date: Dec 2010
Location: Canberra, Australia
Posts: 21,956
macropod has a reputation beyond reputemacropod has a reputation beyond reputemacropod has a reputation beyond reputemacropod has a reputation beyond reputemacropod has a reputation beyond reputemacropod has a reputation beyond reputemacropod has a reputation beyond reputemacropod has a reputation beyond reputemacropod has a reputation beyond reputemacropod has a reputation beyond reputemacropod has a reputation beyond repute
Default

That's because the code I posted was designed only for deleting empty content at the end of a document. Deleting empty pages elsewhere is a far more complex undertaking.
__________________
Cheers,
Paul Edstein
[Fmr MS MVP - Word]
Reply With Quote
  #12  
Old 11-14-2014, 04:48 AM
Dimsok Dimsok is offline Delete blank pages Windows XP Delete blank pages Office 2007
Advanced Beginner
Delete blank pages
 
Join Date: Sep 2014
Location: exUSSR
Posts: 50
Dimsok is on a distinguished road
Default

Hi, Macropod. I have problem with using that macro. Does the job, but after deleteing all blank pages in the end, when i press "enter" to begin new paragraph, new string starts just from the beginning, without any paragraph interval. When i delete all hidden symbols manually all is ok, when press "enter" new paragraf begins instead of continuing previoius.
Reply With Quote
  #13  
Old 11-14-2014, 05:03 AM
macropod's Avatar
macropod macropod is offline Delete blank pages Windows 7 64bit Delete blank pages Office 2010 32bit
Administrator
 
Join Date: Dec 2010
Location: Canberra, Australia
Posts: 21,956
macropod has a reputation beyond reputemacropod has a reputation beyond reputemacropod has a reputation beyond reputemacropod has a reputation beyond reputemacropod has a reputation beyond reputemacropod has a reputation beyond reputemacropod has a reputation beyond reputemacropod has a reputation beyond reputemacropod has a reputation beyond reputemacropod has a reputation beyond reputemacropod has a reputation beyond repute
Default

I suggest you click on the ¶ symbol on the Ribbon's Home tab, so you can see Word's formatting marks. Whenever you press the Enter key on its own, a new ¶ will appear there in the document and the insertion point will move to the start of the new paragraph. The ¶ represents a paragraph break. Pressing the Enter key on its own never merely continues the previous paragraph.
__________________
Cheers,
Paul Edstein
[Fmr MS MVP - Word]
Reply With Quote
  #14  
Old 11-14-2014, 05:17 AM
Dimsok Dimsok is offline Delete blank pages Windows XP Delete blank pages Office 2007
Advanced Beginner
Delete blank pages
 
Join Date: Sep 2014
Location: exUSSR
Posts: 50
Dimsok is on a distinguished road
Default

I have settings in "paragraph" with indentation "first line" "1.25cm". So when i overtype sting and it's automatically continue on new, it begins from the end, and when i press "enter" the new string begins with 1,25 interval. But when i use tha macro, i should change paragraph settings again to do this. Nothing can do with that macro to preserve that settings?
Reply With Quote
  #15  
Old 11-14-2014, 05:34 AM
macropod's Avatar
macropod macropod is offline Delete blank pages Windows 7 64bit Delete blank pages Office 2010 32bit
Administrator
 
Join Date: Dec 2010
Location: Canberra, Australia
Posts: 21,956
macropod has a reputation beyond reputemacropod has a reputation beyond reputemacropod has a reputation beyond reputemacropod has a reputation beyond reputemacropod has a reputation beyond reputemacropod has a reputation beyond reputemacropod has a reputation beyond reputemacropod has a reputation beyond reputemacropod has a reputation beyond reputemacropod has a reputation beyond reputemacropod has a reputation beyond repute
Default

The macro does nothing to affect your document's formatting, other than to delete empty paragraphs at the end.

The problem you're having is most likely due to the fact you've used direct formatting to override a Style definition and the new paragraph is being created, as it should be, without that over-riding. The moral of the story is that you should learn to use Styles properly and to not override them with direct formatting.
__________________
Cheers,
Paul Edstein
[Fmr MS MVP - Word]
Reply With Quote
Reply

Thread Tools
Display Modes


Similar Threads
Thread Thread Starter Forum Replies Last Post
Delete blank pages deleting blank pages thauser Word 3 05-27-2014 01:56 AM
Delete blank pages Deleting blank pages Microsoftenquirer1000 Word 14 08-27-2012 01:24 PM
delete blank pages from mail merge document blusea Word 0 12-17-2010 06:10 PM
How do you delete a blank page at end? aerophil Word 4 10-24-2009 05:04 AM
hidden blank pages mljm Word 3 06-19-2009 03:18 AM

Other Forums: Access Forums

All times are GMT -7. The time now is 04:14 AM.


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