Paragraph selection and page breaks in VBA

Hi,

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.

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

2 Replies
1518 Views

Similar Articles

[PageSpeed] 52

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 + 
ENTER).
All manual line breaks give the _appearance_ of separate paragraphs, but in 
the Word object model, those belong to the same paragraph.

HTH,
Dave
0
Utf
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..

Manfred
0
Utf
12/10/2009 11:47:01 AM
Reply:

Similar Artilces:

VBA code to find first blank cell in a column and activate it
MS XP Pro, MS Office 2007. Can anyone assist with macro to find the first blank cell in a column and then to make it the active (selected) cell so that data can be pasted to it and the row in which it is placed. I cant find a stable and reliable solution with the Find Blank Cell procedure in the menu. When you say first blank cell, do you mean - From the top down, the first blank cell with possibly other non blank cells below that blank cell. or - From the bottom up, the cell below the first non-blank cell. Regards, Peter T "Wes_A" <WesA@discussions.microso...

MsgBox with number of paragraphs formatted with a user-defined paragraph style
Dear Experts: I would like to loop thru all paragraphs and check how many paragraphs have been formatted with a specific user-defined paragraph style (say user-defined-style-1). A Msg Box is to show me the numbers of paragraphs formatted with this style. Help is much appreciated. Thank you very much in advance. Regards, Andreas Something like Dim oSection As Section Dim oPara As Paragraph Dim i As Long i = 0 For Each oSection In ActiveDocument.Sections For Each oPara In oSection.Range.Paragraphs If oPara.Style = "user-defined-style-1" Then i = i + 1 ...

multi-page receipt preview?
Is there a way to view beyond the first page of a multi-page recept in the viewer? I have tried every key combination I can think of to no avail. Marc Marc, Ctrl and right arrow wiil take you to the rest of the receipt. Craig "Marc" <marc_no_spam@beverlyspet.com> wrote in message news:%23WWi8nRzGHA.4648@TK2MSFTNGP04.phx.gbl... > Is there a way to view beyond the first page of a multi-page recept in the > viewer? > I have tried every key combination I can think of to no avail. > > Marc > Control + Right Arrow moves forward Control + Left Arrow moves...

Outlook Select Names (email address and fax)
I currently use Windows XP with Microsoft Outlook 2002. When I want to send an email and need to Select Names from Outlook Contacts, I click on the "To:" button and the Select Names box comes up for me to select the Names I want to send an email. When I find the Names I want to select, there is not only the email address to send the email, but also a fax number (not needed in list). So here is my question: How do I eliminate the fax number from appearing in the Select Names list? Your reply with Answer is very much appreciated. There isn't any way to do it automatica...

Moving Selection
I have a worksheet that I need the selection to follow a certain pattern after Enter is pressed. Example: Enter data in A1 press <Enter> selection moves to A2 Enter data in A2 press <Enter> selection moves to A3 Enter data in A3 press <Enter> selection moves to B1 Enter data in B1 press <Enter> selection moves to B3 Enter data in B3 press <Enter> selection moves to C1 We are entering data in a block as follows: Part #1 Block: D1:K3 (D1, D2, D3, E1, E2, E3, F1, ......, K2, K3) Part #2 Block: D4:K6 Part #2 Block: D7:K9 Anyway to do this? Thanks, Mar...

Body text not on page
The text I type into the page does not appear on the page in the code view. Is there something I need to do ? All that appears after I publish the page is the footer. Hard to say anything without seeing your page online Post a URL to your published page and tell us which text is missing -- _____________________________________________ SBR @ ENJOY (-: [ Microsoft MVP - FrontPage ] "Warning - Using the F1 Key will not break anything!" (-; To find the best Newsgroup for FrontPage support see: http://www.net-sites.com/sitebuilder/newsgroups.asp ________...

Selective Rejection of Email
My Exchange 2003 server is rejecting email from selective domains that I frequently use, such as microsoft.com and a couple of others. I have nothing to change configuration. What could be causing this issue - I'm using Symantec AV to check email. Any suggestions would be appreciated. Thanks. Dan What is the NDR that the senders get back ? Regards Paul Ford Edge IT Ltd "DLS" <DLS@discussions.microsoft.com> wrote in message news:BDCD03FD-43AF-4753-8C21-144F52440450@microsoft.com... > My Exchange 2003 server is rejecting email from selective domains that I > ...

How do I invert a paragraph?
I am printing a "made by" box on the back of a greeting card, and I need to invert it after I type it. How do I do this. The "flip or rotate" on the draw toolbar doesn't work. See http://www.gmayor.com/rotate_text.htm -- <>>< ><<> ><<> <>>< ><<> <>>< <>><<> Graham Mayor - Word MVP My web site www.gmayor.com Word MVP web site http://word.mvps.org <>>< ><<> ><<> <>>< ><<> <>>< <>><&...

Email select page of report -- need help
I am trying email a report to employees. I only want to email one page of the report to each employee. Ex: John Doe gets john doe's page from the report. I have messed with this code and can get it to use my query to send email's with the report attached, but I can't figure out how to filter the report. I need help. THanks in advance. Option Compare Database Private Sub Email_RPT_to_All_Emp_Click() On Error GoTo Some_Err Dim strBody As String, lngCount As Long, lngRSCount As Long Dim db As Database Dim rst As Recordset Set db = Cu...

VBA- Undo?
v2007 Is there no Application.Undo in PPT? If not, has anyone had success using another strategy in VBA for reversing the last action a user did in a slide edit? Thanks, Melina You can call on the Undo button using the following code: Application.CommandBars.ExecuteMso "Undo" - Chirag PowerShow - View multiple PowerPoint slide shows simultaneously http://officeone.mvps.org/powershow/powershow.html "Mel" <mel.turco@yahoo.com> wrote in message news:89f5064e-0901-428a-bdce-9d61f1d2cce0@15g2000yqa.googlegroups.com... > v2007 > > I...

How do i create a bibliography page
I am writing a paper and i have created endnotes now i want to create a bibliography page i am using word 2007 ...

VBA
(PPT 2003 mostly and sometimes 2007) I made a macro for replacing ALL the Arial fonts in my presentation to the font Broadway using: ActivePresentation.Fonts.Replace Original:="Arial", Replacement:="Broadway" But I noticed it doesn't change fonts in certain objects like charts and wordart. Are there others it doesn't change? What code do I need to do change every text object using Arial to Broadway? Thanks, Melina In article <6546560a-4461-463d-9e42- b32dcaf76fa9@a31g2000yqn.googlegroups.com>, Mel wrote: > (PPT 2003 mostly and sometimes...

Dowload file from URL with VBA
I am trying to write a simple access program where the users can download file from internet website. I have the internet Domain and password. What function or command can be used to connect to the internet domain, so that I can have other command to access the file in the internet for dowloading. -- TS Lim You are wanting to FTP files to/from a server. Take a look at http://www.devhut.net/index.php?lang=en&pid=0000000028 -- Hope this helps, Daniel Pineault http://www.cardaconsultants.com/ For Access Tips and Examples: http://www.devhut.net Please rate this post usin...

Outlook 2007 paragraph spacing, reprise
Hello, Perhaps in response to the earlier outcry, the Outlook 2007 (with Vista Ultimate) that I just installed came with the Normal Style defaulting to 0 space after paragraphs. This meant that, typing a new message into the HTML editor, I had to hit Enter twice in order to have any visible space between my paragraphs. This, then, had the effect of sending my messages with an extra paragraph (nbsp) between each paragraph. Still, it looked okay in Outlook. However, it did not look okay to others, in Gmail and elsewhere. And it did not look okay when echoed back to me in the form of replies. S...

Word paragraph default
I can't seem to be able to change the default paragraph style. i have gone into word options, advanced and selected no spacing as default style. But it doesn't hold. Does anyone know how to fix this? If you are using Word 2007 and you want the look of Word 2003, do the following: Create a new, blank document. On the Home tab, click Change Styles | Style Set | Word 2003. Then click Change Styles | Set as Default. If/when you are prompted to save your Normal template, choose to do so. -- Stefan Blom Microsoft Word MVP "zoriana" <zoriana@discussion...

auto load the VBA~
how to set the VBA autoload when i open the excel file ~?! thx a lot~~ The question doesn't make sense, VBA is there with Excel. If you want to run a macro when the workbook opens, name it Auto_Open. -- HTH Bob Phillips "-_-"" <wl925@yahoo.com> wrote in message news:uWbrs%23$lFHA.4056@TK2MSFTNGP10.phx.gbl... > how to set the VBA autoload when i open the excel file ~?! > thx a lot~~ > > thank you~ But i am still confused in VBA and macro. I used the visual basic editor to create a form. and how can I open the form (ie run sub/userform) when i op...

VBA Opening worksheet, name changes
I have a VBA code - that opens a worksheet, then gets data. The problem is that the worksheet name can change, then it won't open. Is there anyway to save the worksheet name as some variable, that can reference the worksheet name/location + will automatically update? Thanks Use the codename not the Excel name. This is usually the same, Sheet1, Sheet2, etc, but it doesn't change if the user changes the Excel name. You use it like Sheet1.Range("A1") instead of Worksheets("Sheet1").Range("A1") -- HTH Bob Phillips "Jeff" <Jeff@di...

Cascading lists column selection
Although I have used Access for several years I am new to VBA coding and am trying to enhance some of the dbases I have built. I am trying to use cascading lists to show values using Case Select rather than query parameters as some of the parameters have lots of choices that I will use to create reports. The problem is that the tables for Specific_Reports RowSource are anywhere from 1-4 columns and the needed information is not in the same relative position in each table How do I change the code or combo box properties to take this into account? Code Select Case avail_reports.Value Case &...

Rank items, select one start date, have remaining dates follow based on rank
I have a list of projects. I have one start date. Each project has a varying amount of time to complete. I want the user to rank the projects based on importance (example when it will ship) and then, based on the individual times required to complete the rest of the projects, excel will automatically generate start and complete dates for the remaining projects. Need to know how to do this. -- rob normerica ------------------------------------------------------------------------ rob normerica's Profile: http://www.excelforum.com/member.php?action=getinfo&userid=26316 View this t...

Add to an Existing formula in a Cell using VBA
Hi, I am trying to figure out how to do the following: Assume you have a formula like sum (A1:A5) in cell A6. What I need to do is add a sumproduct formula to the existing formula using vba. For example, the formula in cell A6 will be updated to sum(A1:A5)/ SUMPRODUCT((C4:C8=B1)*(D4:D8=B2)) Any ideas or suggestions. Thanks, Steve Basic idea. Modify to suit Sub addtoformulawithvba() With ActiveCell MsgBox .Formula ..Formula = .Formula & "+d2" End With End Sub -- Don Guillett Microsoft MVP Excel SalesAid Software dguillett1@austin.rr.com "...

workbook select
Hi, can anyone help me with a macro to select a specific workbook that is already open? The book is called "1234" quotes & orders ( this can be called "any number" quotes and orders during my procedure, the book is switched to another book and fills data from the first book. When the procedure is complete, i need to select the original book from where i started from ("1234" quotes & orders) i might have more books open with the same quotes and orders name but diferent "1234" at the same time. so i would need it to do the following: get name...

Chart Data Table
This probably seems a trivial question but I really can't work it out! Each day I plot a specific currency rate with the date. I have two charts on a worksheet. One shows the graph since I started in 2003 and the other just the current year. When I add data I click on the appropriate graph and a blue rectangle encloses the currency data and a mauve one the dates. Here is my problem - on one chart, when I drag the adjoining handles at the bottom of the table to move it to enclose the new data BOTH rectangles move together however on the other chart only ONE moves so I have to drag t...

Filter Form by Multi Selection
What I would like is to have the selection fields in the header. Based on the values inputted in the header, for the results to be displayed in the main part of the form. When there is nothing selected in the header, for all the data to show. Also, I would like the result data to be updated on tab. I've got the result data the way I would like it. I just cannot figure out how to filter it in a form. I've seen it done before. Download the sample database here: Search form - Handle many optional criteria at: http://allenbrowne.com/ser-62.html It demonstrates how to ha...

Selecting all subfolders for offline usage
We use Outlook2000 with Exchange2000. I have a co-worker who has created a monstrously big set of subfolders (and sub-subfolders) within his inbox. He wants to configure almost all of them for offline usage. The only way that I know to do this is to tediously go through each level and check off every box. Is there a way to select ALL of the boxes, then go back and deselect the few that he doesn't want? Yes, I know the wisest thing to do is to simplify the inbox and get rid of all the sublevels, but the user is not about to change the way he operates. Any help will be most a...

Error on Page Internet Explorer 6
I am getting messages which say error on page which are in a yellow triangle Some internet sites which you normally click on dont respond at times. Muc of the functions of web sites work. javascript is mentioned but the fault is not given I am running Win 2000 Pro and I have loaded SP1 and sun java latest version from web site I have played about with the java controls in Explorer- tools- internet options without sucess I have a net gear hardware firewall. I think as I computer user I'm really stuck and having jus spoken to our pc guy he's got the same problems too Can anyone help me- ...