![]() |
#1
|
|||
|
|||
![]()
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 |
#2
|
||||
|
||||
![]()
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 |
#3
|
|||
|
|||
![]()
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
|
#4
|
||||
|
||||
![]()
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 |
#5
|
|||
|
|||
![]() Quote:
What hidden symbiols? Just ¶¶¶. Is that possible to delete them in the end of document in one click? |
#6
|
||||
|
||||
![]()
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 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 |
#7
|
||||
|
||||
![]() Quote:
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] |
#8
|
|||
|
|||
![]()
I don't have any guess. Just in default. Office 2007.
|
#9
|
|||
|
|||
![]()
Thanks for the codes. That is what i was looking for
|
#10
|
|||
|
|||
![]()
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 |
#11
|
||||
|
||||
![]()
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] |
#12
|
|||
|
|||
![]()
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.
|
#13
|
||||
|
||||
![]()
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] |
#14
|
|||
|
|||
![]()
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?
|
#15
|
||||
|
||||
![]()
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] |
![]() |
Thread Tools | |
Display Modes | |
|
![]() |
||||
Thread | Thread Starter | Forum | Replies | Last Post |
![]() |
thauser | Word | 3 | 05-27-2014 01:56 AM |
![]() |
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 |