Paragraph selection and page breaks in VBA


I'm looping through the paragraphs in a document (i.e. For Each myPara In 
ActiveDocument.Paragraphs) and looking at the style, length of paragraph and 
a number of other things. The trouble I'm having is when two paragraphs are 
separated by a page break rather than a paragraph mark: then VBA recognises 
it as only one paragraph.

Is this "expected" behaviour? I assume that it's a case of my understanding 
of a page break being different to Word's. And does anyone know of a 
(preferably) quick and easy way to overcome this so that VBA recognises it as 
two paragraphs? I could go through and insert a paragraph mark with each page 
break but I wondered if there was a more elegant solution out there...

Many thanks in advance for any help.

12/8/2009 5:17:01 PM
word.vba.general 1023 articles. 0 followers. Follow

2 Replies

Similar Articles

[PageSpeed] 12

Hi Nikki,
Is it expected behavior? Well, that depends, when you write "page break" do 
you mean a "manual line break" (which you insert by pressing SHIFT + ENTER) 
or do you really mean a page break (which you insert by by pressing CTRL + 
All manual line breaks give the _appearance_ of separate paragraphs, but in 
the Word object model, those belong to the same paragraph.

12/8/2009 5:25:01 PM
Hi nikki,

> I'm looping through the paragraphs in a document (i.e. For Each myPara In 
> ActiveDocument.Paragraphs) and looking at the style, length of paragraph and 
> a number of other things. The trouble I'm having is when two paragraphs are 
> separated by a page break rather than a paragraph mark: then VBA recognises 
> it as only one paragraph.

there are also issues wiht hidden text, especially when paragraph marks are 
included. Always show hidden text, when You iterate through paragraphs..

12/10/2009 11:47:01 AM

Similar Artilces:

paragraph breaks
Occasionally, I have a paragraph break correctly showing an extra blank line. But it won't take my cursor. There are breaks above and below that will. What version Publisher? There is very good help for you in the help files. Type paragraph break in the search. -- Mary Sauer MSFT MVP news:// "sussertown" <> wrote in message > Occasionally, I have a paragraph break correctly showing an extra blank li...

extended stored procedure and "A significant part of sql server process memory has been paged out"
After calling my extended stored procedure I am getting the error: "A significant part of sql server process memory has been paged out. This may result in performance degradation" There don't seem to be any other errors, but I am wondering if anyone else has experienced this. I am using SQL 2005 on Windows 2003 Server. I know Extended Stored Procedures are supposed to be updated to CLR but sometimes it is just not possible. Thanks. Google seems to return tons of links about that. For example : and in particul...

Blank pages
This morning, on both my laptop and desktop using IE8 8.0.7600.16385, certain stories on "disappear" after a few seconds. It also occurs in the online version of, part of the same group. I downloaded Firefox and there is no problem. It seems unlikely IE could have been corrupted on both machines. Is there some add-on I need? Thanks Bill Hi, Tools> uncheck InPrivate Filtering Regards. "Bill" <> wrote in message news:OrAS9scqKHA.5940@TK2MSFTNGP02.phx.gbl... > This morning, on both my la...

position of chart on page moves when outline expands
Hi, I have two charts I have made to the right of a budget table. The top chart is positioned near the top of the page, the second, a smaller summary chart is just under the first one. Problem is, the Budget table is an expandable outline that can expand by dozens of rows. When in expanded mode, the second chart moves way down off the visible page and is only viewable by scrolling, unless I collapse the outline again. The first chart is anchored at the top where little expansion takes place, thus little movement. Is there any way I can prevent this second chart from moving down when ...

Why do I have two consecutive pages numbered "1"?
I have a paginated document that contains two pages numbered "1". I've tried reformatting. Can't figure it out. Most likely because the pages are in different Sections. If you have the non-printing characters displayed (�) you'll be able to determine where the Section Break occurs. Either remove the break or change the properties of the page numbering in the following section to continue from previous. HTH |:>) Bob Jones [MVP] Office:Mac On 1/14/10 4:38 PM, in article, "Sommervi" <So...

How do I move a paragraph from below to above another paragraph
How do I re-position a paragraph above another? Cut and paste. or Select the whole paragraph and drag it to the new position. -- <>>< ><<> ><<> <>>< ><<> <>>< <>><<> Graham Mayor - Word MVP My web site Word MVP web site <>>< ><<> ><<> <>>< ><<> <>>< <>><<> "Scarlett" <> wrote in message news:429061F5-8436-4A1A...

How to format a paragraph.
Is there anyway of laying out a format in Excel so that typing a paragraph will cause the paragraph to be broken up into a series of justified lines, each line having several words in it? Don J --------------------------------------------------------------------------- You can merge cells -- and format them to wrap the text ... then type your text... How large of a paragraph? Excel is not designed to do large amounts of text. Another option is a text box "floating" over your cells. Kate G. "Don J" <dej8801@...

How do I turn a website with multiple pages into a single pdf doc
here is the situation. I have created a website with multiple pages using publisher. I want the whole document, every page included to be shown when I convert it into a pdf. file. Unfortunately, when I do this it will only turn one page into a pdf format. Please someone help me with this What program are you using to create your .pdfs? -- JoAnn Paules MVP Microsoft [Publisher] ~~~~~ How to ask a question "Ted Wickund" <Ted> wrote in message

Report Server Name in VBA
I'm adding a button in GP to launch an SRS report, but I don't want to hard code the report server name in the VBA. The button will no longer work if the client ever changes their report server. I'd like to pull the report server name and append the report name and parameter to create the URL I'm using to call the report. Is there any way to dynamically determine the report server in VBA - perhaps thru a dll? Thanks in advance! ba_wvu: Try this: 1. Add the Report Server window to your VBA project (Tools - Setup - System - SQL reporting services 2. Add the Cancel Bu...

selected data not shown in graph and axis labels
I am making a graph of data collected from Sept.-Feb. where the x-axis is the date and the y-axis is the value collected. I have several different series of data and selected the appropriate cells for the data and for my x-axis labels, but my chart is only showing the data from Sept.-Jan.. Why is this? Thank you Tell us how the data is set out: x-values in range A1:A20 (tell us your real range) y1 in B1:B20 (tell us your range), y2 in where What type of chart? -- Bernard V Liengme remove caps from email "QuantumLeap" <QuantumLeap@discussions....

how is it possible to have paragraph marks inside a paragraph?
i had to correct a text and it had a paragraph sign in the middle of the paragraph (in normal view it showed only one paragraph in the margin, but the text itself had this paragraph mark and the text continued on the next line) however, when i click on the paragraph name in the margin, it selects all text (even the bit after the paragraph mark). i've never seen that before, can anyone help me? thanks If you turn off hidden characters, is it still there? -- JoAnn Paules MVP Microsoft [Publisher] Tech Editor for "Microsoft Publisher 2007 For Dummies" "...

How do I count selected controls in a formula
I have a worksheet that is my log of occupational injuries and illnesses. Each row is a unique record for which information is recorded in the columns. Four of the columns request and "check mark" to select the right classification of injury. Because only one of these columns can have a check mark, I've placed option buttons from the Control Toolbox in them. Two questions: 1) At the bottom of each column is a totals line. How do I write a formula in the cell that counts the total number of option boxes that have been selected in the column? And doing so without kno...

how print non-continguous selected rows of worksheet?
Thanks in advance. I have a tall (worksheet with lots of rows) and I need to print only a few of the non-continguous rows (to check numbers with another worksheet). I selected the rows I wanted to print (by clicking on the row number at the left and using ctrl-click to select other rows). But when I printed, each row is on a separate page, I would like them to be on the same page. Any ideas? Thanks again. > Any ideas? Not how to do that. But since you've gone so far already, you're only 4 clicks away from a "workround". 1 Copy button. 2 New (file) button 3. Paste...

VBA code needed
i am trying to retrieve a range of data (the stock code of different phones) from worksheet("Inventory") based on the name of the branches of where the phones are stored. worksheet("Inventory") has branch (Column A) and stock code (Column B) i have 2 combobox. combobox1 contains values (name of branches) such as: 1-BS 2-EN 3-HG 4-JE 5-SP 6-TB 7-WS 8-YT combobox2 will have to retrieve values from the worksheet("Inventory") based on the value in combobox1. the values in combobox1 can be found in column 1 while the values i need for combobox...

Turn on paragraph marks?
Hi: I am using word 2003 and XP. I have had paragraph marks and formatting characters turned on (Tools, Options, formatting marks checked) since I initially set up word years ago. Recently, when I open documents, the formatting marks no longer appear. When I go to Tools, Options ... , the formatting marks are no longer checked off. (And, when I check them off .. the marks appear in the document I am currently working on, but Word reverts to no formatting marks the next time I open it.) Any suggestions on how I can get the formatting marks to stay? d Since setting...

CRichEditCtrl + selection(shift + end)
hi in my application i am doing syntax highlighting. currently i am able to color the keywords. but there is one problem. if i select this portion of keyword (which is in blue color) with keyboard (shift + End) then the color get's contrast if i select the same text with mouse then it does not disturb. why something like this is happening? is the selection with keyboard and mouse are different in functionaliy? If anybody know's please suggest some solution. CRichEditCtrl creation code is like this m_rich.Create(ES_AUTOVSCROLL |ES_AUTOHSCROLL | ES_NOHIDESEL | ES_MULTILI...

How do i print divider page tabs?
I use 3 ring binders extensively and prefer to print out the tab inserts for the divider ages. But I can't find that in Word 2007. Does anyone know where to find that? Try searching the internet for a template for these Dividers. I believe I found the one that I use on Avery site years ago and have custimsed it since. Also, remember that when printing you have to change the Print settings to an "oversize" for the page size you are using, mine is Oversize A4. Also ensure that your printer itself can handle with these, I have to rotate the print job by 180degs to g...

printing selection
I want to print a selection. I select the proper cells, but there is an extra row that prints at the top. It is always the same row, so perhaps I have it locked in some way. How do I get rid of it? It happens only on this one worksheet. Under Page setup, check the Sheet tab, make sure you don't have a row called out or anything. -- Best Regards, Luke M "Anniel" <> wrote in message >I want to print a selection. I select the proper cells, but there is an &...

selecting specific data #3
Hi everyone I have another little problem. I have got a list of 20 items on sheet1, Cells A1 - A20 (numbered 1 - 20) and Cells B1 - B20 are items relating to that number, ie, number 1 = Concrete, number 2 = walls, and so on. Now on sheet 2 I have a table, again cell range A1:B20. I would like to know a formula so that when I enter a number in to column A, the corresponding item to that number appears in column B. ie, if I enter number 8 in Cell A1 on sheet 2, then I would like Floor to appear in Cell B1. Does this make sense? -- Thanks in advance for your help Lee -- Thanks in advance...

Static Date and Time and VBA editing
Hello all, I have no idea how to write VB and have spent an extensive a mount of time doing trial and error. The following code is what I currently use that does the following: It updates columns A and B to uppercase letters when a user enters a lowercase one, and it updates certain columns with current date and time that data was entered in the cell to the left. As of yesterday, I thought this was working, however when I opened the sheet today, all of the times and date updated to the time I opened the sheet. The idea is to have the cells value never change once it is populated with...

Spaces at the start of paragraphs
Whenever I cut & paste text from Word to Publisher, I get a single space at the start of each paragraph - who do I switch this off? >-----Original Message----- >Whenever I cut & paste text from Word to Publisher, I get a single space at >the start of each paragraph - who do I switch this off? >. > Some time ago, I stopped copying directly from any document type other than Publisher. I first paste the text into Notepad to remove all formatting. Then select all, copy and then paste into Publisher. Yes, you will have to do the formatting that Publisher understands and...

Custom Page Size Printing
I am running Windows Vista Home Premium & MS Office 2007. I setup custom page size of 5.5 x 8.5 (sandard size or formal invitations). I setup a Microsoft Access 2007 Report using this page size. I am printing on a HP Color LaserJet 2600n. when I print the printer recogizes the paper in the tray as being valid, but prints the image ~1.5 inches off center to the left. I then setup a custom page size of 8.5 x 8. and used it. I printer recogizes that the paper in the tray is incorrect and asks me if I wish to override and then prints. This issue with that is that if you are pri...

Browse to select a folder
Excel 2003-2007 An OP posted a problem and I realized that there was one thing I needed to know before I could help him. What is the code to allow the user to select a folder? The result must be the full path to that folder. Note: That path will not be the path to ThisWorkbook. Thanks for your time. Otto See a example in the macro on this page 'Browse to the folder with CSV files Set oApp = CreateObject("Shell.Application") Set oFolder = oApp.BrowseForFolder(0, "Select folder with CSV files", 512) If ...

if a paragraph has a particular style
I'm working on a sub to (1) search for a particular style, (2) move to the preceding paragraph, (3) check what style it is, and (4) if it's the style "Heading 2", move back to the following paragraph and do something. It's step 3 that's giving me trouble. How do I say: if the paragraph has a particular style... This is what I've got, but it doesn't work. If .Style = wdStyleHeading2 Then Thank you in advance, ~ Janet Hi Janet, Use: Dim prange As Range Dim i As Long Selection.HomeKey wdStory Selection.Find.ClearFormat...

openning windowa explorer and selecting a file
Hi, I'm looking for an API function that opens the windows explorer on a specific folder and selecting a file in it. I know that the function 'ShellExecute' can open windows explorer but can it select a file (like after downloading a file and pressing 'open folder' and the folder is opened and the downloaded file is selected). Thanks, Ram. > I know that the function 'ShellExecute' can open windows > explorer but can it select a file (like after downloading After you do ShellExecute() as you say you can. Use Spy++ to see if can find the window with FindWi...