Go Back  Xtreme Visual Basic Talk > Visual Basic .NET (2002/2003/2005/2008, including Express editions) > .NET Office Automation > HOW TO: Delete a page in a MS Word Document?


Reply
 
Thread Tools Display Modes
  #1  
Old 12-21-2004, 11:23 AM
mOrrI_sEm_sAbEr mOrrI_sEm_sAbEr is offline
Newcomer
 
Join Date: Dec 2004
Posts: 14
Question HOW TO: Delete a page in a MS Word Document?


Heyas...
i was wondering if anyone knows how to delete a page in a word document using VB .net???

i got a document with 2 pages and i want to delete the last page of the document... can anyone help me on this one?...
thanks in advance...
Reply With Quote
  #2  
Old 12-21-2004, 11:29 AM
Mike Rosenblum's Avatar
Mike Rosenblum Mike Rosenblum is offline
Microsoft Excel MVP

Forum Leader
* Guru *
 
Join Date: Jul 2003
Location: New York, NY, USA
Posts: 7,848
Default

I'm no Word guy at all... but have you tried opening up Word, turning on the Macro Recorder, and then seeing what result it gives? From there you'll have to clean up the code and convert it to .Net-style, but the Macro Recorder is definately where I would begin.

Also, what do you mean by "delete the 2nd page". Do you mean delete enough text at the end such that it no longer rolls over to the 2nd page? Or is this a printing situation and you only want to print Page 1?
__________________
My Articles:
| Excel from .NET | Excel RibbonX using VBA | Excel from VB6 | CVErr in .NET | MVP |
Avatar by Lebb
Reply With Quote
  #3  
Old 12-21-2004, 11:32 AM
mOrrI_sEm_sAbEr mOrrI_sEm_sAbEr is offline
Newcomer
 
Join Date: Dec 2004
Posts: 14
Default

heyas, well i have 2 pages... and i want to delete the 2 page completly... so that in the end i will have only 1 page in my document...
Reply With Quote
  #4  
Old 12-21-2004, 11:49 AM
Mike Rosenblum's Avatar
Mike Rosenblum Mike Rosenblum is offline
Microsoft Excel MVP

Forum Leader
* Guru *
 
Join Date: Jul 2003
Location: New York, NY, USA
Posts: 7,848
Default

Use the Macro Recorder to figure out how to delete text.

I'm no Word guy at all, but I guess you would keep deleting text, one-by-one, until
Code:
ThisDocument.Windows(1).Panes(1).Pages.Count = 1
There may be a better way to do this, but given how little I know about the Word Object Model, this is the best I could do.
__________________
My Articles:
| Excel from .NET | Excel RibbonX using VBA | Excel from VB6 | CVErr in .NET | MVP |
Avatar by Lebb
Reply With Quote
  #5  
Old 12-21-2004, 02:51 PM
herilane's Avatar
herilane herilane is offline
Unashamed geek

Retired Moderator
* Expert *
 
Join Date: Jul 2003
Location: London, England
Posts: 8,988
Default

Is there a page break between the two pages? Or any other way to recognize where page 2 starts?
Reply With Quote
Reply


Currently Active Users Viewing This Thread: 1 (0 members and 1 guests)
 
Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off

Forum Jump

Advertisement:





Free Publications
The ASP.NET 2.0 Anthology
101 Essential Tips, Tricks & Hacks - Free 156 Page Preview. Learn the most practical features and best approaches for ASP.NET.
subscribe
Programmers Heaven C# School Book -Free 338 Page eBook
The Programmers Heaven C# School book covers the .NET framework and the C# language.
subscribe
Build Your Own ASP.NET 3.5 Web Site Using C# & VB, 3rd Edition - Free 219 Page Preview!
This comprehensive step-by-step guide will help get your database-driven ASP.NET web site up and running in no time..
subscribe
 
 
-->