Home | Contact Us | FAQ | Search & Site Map | Link to Us
Sign In | Join | Other 45 Sites in Network
Home
DiscussionsAccessExcelInfoPathOutlookPowerPointPublisherWord
DirectoryUser Groups
Related Topics
Outlook ExpressInternet ExplorerWindowsMS Server ProductsMore Topics ...

MS Office Forum / Word / Programming / January 2006

Tip: Looking for answers? Try searching our database.

Deletion of Empty Page in the Word Document through VBA

Thread view: 
Enable EMail Alerts  Start New Thread
Thread rating: 
Kiruthiga - 17 Jan 2006 14:10 GMT
Hi all,

This is to request for your help in this MS Word issue. In the VB
application we are required to copy and paste temporary documents (containing
text, pictures, etc) into a single, final word document.



The main document contains tables and the issue is related w.r.to tables. In
the current application, the .rtf file is formed from the html file.



While copying, the blank pages get inserted in the document if the control
is in the ‘last but one’ row of a table and sometimes if the control is in
the last row during document generation process. This causes the extra page
in the document and page numbers are counted for this.



We are working on Windows 2000 Server as our OS.



In the existing code, section breaks (Next Page) are used. I am trying to
scan each and every page and finding if any empty page is there. If so, I
have planned to pass the delete key to delete the empty page.



Could you provide any pointers as how to go about this?



I need to scan each and every page of word doc and need to find if any blank
page is there. If so I need to delete the page programmatically.



Any help in this issue would be greatly appreciated.





Regards,

Kiruthiga.S
rVo - 17 Jan 2006 16:42 GMT
I solved thi sin a similar project by doing a find and replace (record it as
macro)
and use
the comment signs are there to avoid our firewall from going bananas on this
post ;-)

       '    Selection.Find.ClearFormatting
       '    Selection.Find.Replacement.ClearFormatting
       '    With Selection.Find
       '        .Text = ChrW(12) & vbCr & ChrW(12)
       '        .Replacement.Text = ChrW(12)
       '        .Forward = True
       '        .Wrap = wdFindContinue
       '    End With
       '    Selection.Find.Execute Replace:=wdReplaceAll

chrw(12) is the code for a pagebreak

Hope this helps,

rVo

> Hi all,
>
[quoted text clipped - 26 lines]
>
> Kiruthiga.S
Kiruthiga - 18 Jan 2006 09:50 GMT
Hi rVo,

Thanks a lot.

I have used the below code to delete the empty page. Could you please tell
me whether this is feasible. It deleted the blank page but i am not sure
whether it will work out for all cases. It will be great if you provide me
some tips on it.

wrdselection.Find.ClearFormatting
   wrdselection.Find.Replacement.ClearFormatting
   With wrdselection.Find
       .Text = "^b"
       .Replacement.Text = ""
       .Forward = True
       .Wrap = wdFindContinue
       
   End With
   wrdselection.Find.Execute Replace:=wdReplaceAll

Also i am trying to scan each and every page and finding if it ia blank
page. if so i am deleting it using range property.

Regards
Kiruthiga

> I solved thi sin a similar project by doing a find and replace (record it as
> macro)
[quoted text clipped - 52 lines]
> >
> > Kiruthiga.S
Kiruthiga - 18 Jan 2006 11:52 GMT
Hi rVo,

The find string "^b" is not working. Also the string that you have given
also doesn't work.

The document which i am using has section breaks and page breaks.

Could you please help me to resolve the issue.

Regards
Kiruthiga

> Hi rVo,
>
[quoted text clipped - 78 lines]
> > >
> > > Kiruthiga.S
 
Sign In
Join
My Latest Posts
My Monitored Threads
My Blog
My Photo Gallery
My Profile
My Homepage

Start New Thread
Enable EMail Alerts
Rate this Thread



©2008 Advenet LLC   Privacy Policy - Terms of Use
This website includes both content owned or controlled by Advenet as well as content owned or controlled by third parties.