Tracking Forums, Newsgroups, Maling Lists
Home Scripts Tutorials Tracker Forums
 
  HOME    TRACKER    Visual Basic




Word VB: Paragraph End


Hi folks,

I am iterating through a range.paragraphs, catching each paragraph and modifying the begining and the end.
Is there a direct approach to get to the end of paragraph( basically the last non white space character). I am trying the range.endof with unit as paragraph and actually get the first letter of the next para.

Any help would be appreciated.
thanks.




View Complete Forum Thread with Replies

See Related Forum Messages: Follow the Links Below to View Complete Thread
Add Paragraph In Word File Through Vb6.0
i wnt to add text in file as the value of one text box as one paragraph, second text box'value as 2nd paraph and 3rd as textbox 'value as 3rd paragraph????how can i add that???

Word GOTO Paragraph
Hi friends,

What is the best way to navigate to a particular paragraph? For eg., I want to go to the 21st paragraph. What should I do?

At present I am using the following code to do this. The code is:
Code:Selection.HomeKey Unit:=wdStory
Selection.MoveDown Unit:=wdParagraph, Count:=myParaCount 'myParaCount is a variable


Is there anyother way to do this, because, this one is very slow, if I operate this on a big document?

Thanks
Srik

[Anyone?] Need Help With Paragraph Alignment In MS-Word
EDIT: Still looking for suggestions! Would it help to move this question to the general VB.Net forum? Thanks!

Hello and thank you for reading my post!

My problem is actually with Visual Basic.Net programming in MS-Word, and not strictly VBA, but this seemed like the best place to post my issue.
If anyone feels this should be posted in a different forum, please let me know so that I can make the change!

Problem: I cannot affect the alignment of an MS-Word paragraph from within a VB.Net windows application.
I have tried many different permutations, but none have any affect. The code below contains what I believe should work, but it does not.

In particular, I am invoking the following statement to affect alignment:
pghTotal.Range.ParagraphFormat.Alignment = Word.WdParagraphAlignment.wdAlignParagraphCenter

I have also tried to affect the alignment at the Word.Application level, Selection level, Paragraph level, Range level, etc. Nothing has worked.

I would greatly appreciate any comments! Thank you very much!

Code:Imports Word = Microsoft.Office.Interop.Word

.
.
.

Private Sub Statements_Process_One(ByRef statement As CStatement, ByRef appword As Word.Application)

' declare MS-WORD variables
Dim docStatement As Word.Document
Dim pghTotal As Word.Paragraph

docStatement = appword.Documents.Add(constant.TEMPLATE_STATEMENT)

.
.
.

Dim strMessage As String = ""
strMessage = constant.MSG_STATEMENT_TOTAL.Replace("&TOTAL", FormatCurrency(decBal))
pghTotal = docStatement.Content.Paragraphs.Add(docStatement.Bookmarks.Item("endofdoc").Range)
pghTotal.Range.ParagraphFormat.Alignment = Word.WdParagraphAlignment.wdAlignParagraphCenter
pghTotal.Range.Font.Bold = True
pghTotal.Range.Font.Italic = False
pghTotal.Range.Font.Color = Word.WdColor.wdColorBlue
pghTotal.Range.Font.Size = 14
pghTotal.Range.Text = strMessage & Environment.NewLine

.
.
.

End Sub

Frank Roscoe - Technology Manager
Vehicle Service Equipment
www.vsequip.com

Edited by - froscoe on 7/5/2006 5:53:50 AM

Paragraph Capture In Word Using VB
Hi all....

I need to capture a set of paragraphs in MSWord using a VB application to fill in a DataBase.
The fields will be in three different and consecutive paragraphs in Word 97.
How can I do this capture?

Word Paragraph Formating Stumper!
I am trying to write some VBA code that formats some text in a Word document and am stumped on how to do a particular procedure. Without gettting to long winded the document is a Questionairre with a layout like this....

'*********************************************************
11. This is a sample question with several
sentences that spill over several lines.
There are several tab stops that contain
various answers to the question ...............1.......2.......3.......4.......5

'*********************************************************

I run some code that deletes all the tabs. I want the question to now extend the entire length of the page but it doesnt. So after I delete the tabs the question looks like this.


'*********************************************************
11. This is a sample question with several
sentences that spill over several lines.
There are several tab stops that contain
various answers to the question
'*********************************************************

But I want it to look like this.....

'*********************************************************
11. This is a sample question with several sentences that spill over several lines. There are several tab stops that contain various answers to the question
'*********************************************************

If I manually go to the end of the first line and push delete the second line will then jump up to the first line and I get the desired format but it seems to me that there must be some code or a property that can accomplish this? Does anyone have any suggestions?

Thanks!!

Mike

Accesing The Paragraph By Selecting The TOC In Word
Hello,

I am trying to delete the content in the word document by highlighting the field in the TOC.

For e.g when I hightlight the Chapter 1 in the Table of Content it should create a new word document without the Chapter 1.

Could someone please help me with this. I am able to access the contents if I specify the Paragraph no.

But could someone tell me how do I get link the TOC and the Paragraphs in the content,

Thanks,

How Do You Reference The Paragraph Mark In Word
Hi,

What is the way to refer to a paragraph mark in Word?

I want to say like, If Footer = ( reference for paragraph mark - chr(something) ??)

Thank you

Vba Code For Selecting A Paragraph In Word
In Word -- Can anyone tell me the vba code for selecting the entire paragraph currently containing the insertion point? Thanks.

Word 97 - Extend Selection To End Of Paragraph? (fixed)
I can extend to the end of a line "Selection.EndKey Unit:=wdLine, Extend:=wdExtend"
But how do I extend to the end of the paragraph? "Selection.EndOf Unit:=wdParagraph, Extend:=wdExtend" doesn't work?


<EDIT>Actually it does. Forget I asked....</EDIT>


 

Edited by - RicardoSmith on 8/20/2003 9:12:11 AM

Paragraph Creation And Passing It's Text From The VB Form To Word Doc.
Hi,
I am new to the Creation Of Word/Excel Objects.
I am developing an application in VB. A Word Document is created at the click event of a button from the form.
I want to pass some text in the initial two paragraphs of the document while it is created. Till now I am unable to pass this text.

Please do provide your suggestions or links for this problem.
--

How To Capture Mouse-click Event For A Paragraph In MS WORD.
Friends,
Some of the buttons in MS office toolbars have additional functionality when you double click them.. e.g. Format painter button in Word. When this button is double clicked it stays selected and subsequent document clicks are captured and the selected word/sentence are formatted. I want to make a similar button which remains pressed when it is double clicked and then inserts a word at the curser position whenever i click the document.
Would be glad if someone helps me in this.
Laila

Character, Word, Sentence, && Paragraph Counts Of A Text File
I am between a newbie and a general question.
Yes it is homework. I am not looking for the whole answer just pointed in the correct direction.
I have to configure for these items (Character, Word, Sentence, & Paragraph counts of a text file) inside a class read-only property. The file will come from either a string, which was entered into a text box by the user in they application and then "set" into the class string property via aclass read-write property or a file from a openfiledialog choice by the user which would go into the read-only property.

Word.Fields Creates Difference Between Selection.Range And Paragraph.Characters()
Context: VB6, fields preceding or in selection.

Primary Question: Given a Word.Field, how can I determine its display length -- the length of text displayed to the user.

I've now run into my second instance where Word field codes are throwing off my code for selecting text in a paragraph, when the field codes are in the same paragraph but precede the selection.

It looks like Selection.Range.Start and End use the Field.Code length while Paragraph.Characters() does not. Therefore, whenever I base my Characters() index on Selection.Range.Start or End and there is one or more preceding fields, my index is too large (and sometimes greater than Characters().Count).

My last approach, to determine the field code's display length was:


Code:
' Determine the display length of the given field code.
Public Function GetFieldDisplayLength(ByRef f As Word.Field) As Long
Dim length As Long
' If this field's codes are displayed, use that length
If (f.ShowCodes) Then
length = Len(f.Code)
' Else, use the field's result length
Else
length = Len(f.Result)
End If
GetFieldDisplayLength = length
End Function
Unfortunately, Word.Field.Result is not always what is displayed to the user. I have some fields that do not have a display length yet do have a result.

Continuing this approach, once I can determine the display length of a field code, I can convert Selection.Range.Start or End into the equivalent value within Paragraph.Characters().

Any ideas? Is there an alternative approach? Thank you.

How To Display Multiline Paragraph And Input Multiline Paragraph In What Vb Control?
good day to all! how can i display multiline paragraph? and how can i input such paragraph in a multiline way. What vb control will i use, can you give me some code to extract idea from it?

Getting Current Paragraph
Hi,

I'm trying to find a way of identifying the current paragraph in powerpoint for an item of text that I have selected in VBA.

What I'm trying to do is apply bullet points to certain paragraphs. I have found how to set the bullet points - but I need to identify the start and end paragraphs. So far I have selected the first line of text that I want to change (a paragraph on its own), but can find no way of idetifying the paragraph number for the selected text.

Any ideas anyone??

1st Line Of 1st Paragraph
I cant find a way to identify lst line of 1st paragraph.

I need to check whether its font size if font.size = 16..

anyone knows ??? 10 XXX

Running A Sub On Every Paragraph?
I have a small Sub that I want to run on every paragraph in a document.

I figured I could use a For Each loop, but the syntax is not working. Any help would be MUCH appreciated.

This code does not work:
Public Sub ForEachParagraph()
'Run sub on every paragraph in document

'Loop through each paragraph
For Each Paragraph In Paragraphs

'Call Sub MoveTimeStamp
Call MoveTimeStamp

Next Paragraph

End Sub

Select Paragraph
Hello

I need to incorporate code into a Word macro. I need it to search the current document for the occurrence of the word "all" and then delete the entire paragraph containing the word.

Some code examples would be great

Thanks

String Into Paragraph
I have a string coming out of a database that I have to convert into a nice paragraph and print out. I am using "Printer" to print out my string.

When it comes out of the database it looks like this:

"Dear Mr. Smith, We are please to inform you that you have been aware the contract. We appreciate your help. Sincerely, Mr. Garcia"

And it should look like this after printing:

"Dear Mr. Smith,
We are please to inform you that you have been aware the contract. We appreciate your help.
Sincerely,
Mr. Garcia"

How do I format it so it can look the way I want it when I print it out?

Thanks

Getting Rid Of Paragraph Markers
I am trying to see if there is a way to search for paragraph markers in a variable. I know that it is not usually a visible piece of the text and that is why I can't seem to figure out how to find it. Any help would be greatly appreciated.

Select Paragraph
sir,
how can i select a paragraph in richtext box using code.... i want to select paragraph to appy particular styles. for example... body text, heading, subheading, intro etc.

Paragraph Numbering
Is there a way to apply numbering to paragraphs like SELBULLET does for bullets? If there isn't a built-in function, any suggestions on how to simulate it?

Any suggestions will be appreciated.

Thanks

Paragraph In TextBox
I have one problem: Im making a html program and when I click on a button to insert the &lt;html&gt; and head tags, it writes this:
&lt;html&gt;&lt;head&gt;
Because i use SelText.
I want it to be like this:
&lt;html&gt;
&lt;head&gt;

------------------
ShadowSpy

Paragraph Indent
I have a text box, (it might become a RTB)
I would like to format indented paragraphs that word wrap within the paragraph. EX(I hope it works )
SERVICE
****GROUNDING
*******The electrical service entrance and distribution system
*******equipment shall be grounded as follows and as shown in the
*******electrical details; in compliance with NEC article 250 and state
*******and local codes.
**********1. Ground neutral at main service equipment to available
**************underground water piping over 10 ft. long and to 3/4"
**************Dia. 10 ft. long copperweld driven ground rod(s).

If someone edits the above I would like word wraping so that the text is left justified within its respective paragraph.
Is it possible to to with a text box or a rich text box?
thank you for your time and have a good day

------------------
I am so skeptacle, I can hardly believe it!


[This message has been edited by badgers (edited 01-10-2000).]

[This message has been edited by badgers (edited 01-10-2000).]

[This message has been edited by badgers (edited 01-10-2000).]

[This message has been edited by badgers (edited 01-10-2000).]

[This message has been edited by badgers (edited 01-10-2000).]

Inner HTML Of Whole Paragraph
Hi! :-)

How to access the Inner HTML of the whole paragraph (s) inside which the current selections/or caret lies?

Waiting for your suggestion,

Softpro2k

Inserting Into Paragraph
Hi,


I have many documents which contains xml tags also.

There are various lists within my document.

Ordered lists, bulleted list etc etc

Now these lists have been partially tagged

Example

<ul>
Part4
part5
part 12
</ul>


Now my problem is i have to manually include the <item> and </item> tags so that it looks like the following.

<ul>
<item>part4</item>
<item>part5</item>
<item>part6</item>
</ul>

How can i make this automatic. I m new to VBA and it would be nice if some one could help.

Thanks in advance

Paragraph Indenting With TextBox
When using a VB Code Window, you can select multiple lines, and then when you press tab (or shift + tab) the entire block is moved either to left or right by inserting a character (or a few) at the beginning of each line. How can I emulate this effect using only an ordinary TextBox?

Paragraph Break In MAPI
how do you enter a paragraph break into a string when sending messages via MAPI. for example:

supplier name: xxxxxx

supplier id: xxxxxx

is it possible for normal string variables or is there something else that needs to be done to allow this?

any help is greatly appreciated. thanks

Insert String In Paragraph
Hi,

Can someone show me how to insert string in front of every paragraph in a Word document? Thanks!

Add Line Number In Paragraph
Hi,

Good Day!
How can i add line number for each paragraph in MS Word Document without messing-up the format of the paragraph? The line number will appear only in the first line of the paragraph.

Thanks!

How To Save Paragraph Settings
I need to be able to preserve all the format settings in a given paragraph and then after making some edits in the document, restore the settings.

How can I do this without having to resort to saving every format value individually?

How To Find The Paragraph Of A Range
i need to get the paragraph of the selection(no text selected), a code that run fastly,pl.

Bookmark Paragraph Number
I need help trying to retrieve the paragraph number of a bookmark. I'm inserting data from Excel to the location of the bookmark. The problem is that the location of the bookmark changes depending on upon the products being described in the document. Here is the code I'm using to bring the text in:

ActiveDocument.Paragraphs(i).Range.Text = Range("Text")

I would like to set i = to the value of the paragraph of the bookmark.

HELP

ahays

Setting Paragraph Style
I have an autotext entry (an address) which is automatically executed from a vbform.

My normal style has a 12pt para spacing above.

The problem is, the autotext entry comes in with 12pt spacing above, i want it to come in as 0. the autotext itself is 0, just it re-applies the normal style to it.

I can't do the blimmen obvious and change the normal style to 0pt above. Have tried setting the address to a different style with no luck either.

have also tried


Code:
Selection.ParagraphFormat.SpaceBefore = 0

to no avail.

How To Identify The Paragraph Number
Hi,

I'm trying to write a bit of vb to allow me to review documents by inserting comments. The comments should then be filtered out into a new document for return to the author, along with a paragraph reference for each.

I've got most of it working, just can't figure out how to identify the paragraph number. I'd like it in a format similar to a cross-reference, e.g. Para 1.2.5(a) etc..

Any ideas?

Cheers

Ian

Anchoring Textbox To Top Of First Paragraph
Hello,
I have a macro in Word which is used to create a document from scratch.
It's a standard appointment letter, with a logo in the header.

It then inserts a few textboxes which should only be at the top of the first page (the address, etc)

The problem is, with one of the letters the text is so long it carries over to the next page, meaning the text boxes drop down to the next page and dissapear from the first page.

I've been trying for three hours now to anchor one of the text boxes to the first paragraph in VBA, but I simply cannot work it out.

Someone, please, help!

Here is what I have:


Code:
ActiveDocument.Shapes.AddTextbox(Orientation:=msoTextOrientationHorizontal, _
Left:=250, Top:=65, Width:=150, Height:=100).Select
With Selection
.Font.Name = "Arial"
.Font.Size = 9
.Collapse
End With
With Selection
.TypeText Text:="Resource Centre"
.TypeParagraph
.TypeText Text:="******"
.TypeParagraph
.TypeText Text:="******"
.TypeParagraph
.TypeText Text:="GLASGOW"
.TypeParagraph
.TypeText Text:="******"
.TypeParagraph
.TypeText Text:="Telephone: ********"
.TypeParagraph
.TypeText Text:="Fax: **********"
.TypeParagraph

.ShapeRange.TextFrame.TextRange.Select
.ShapeRange.Fill.Visible = msoFalse
.ShapeRange.Fill.Transparency = 0#
.ShapeRange.Line.Transparency = 0#
.ShapeRange.Line.Visible = msoFalse
.ShapeRange.LockAspectRatio = msoFalse
.ShapeRange.RelativeHorizontalPosition = _
wdRelativeHorizontalPositionColumn
.ShapeRange.RelativeVerticalPosition = _
wdRelativeVerticalPositionPage
.ShapeRange.LockAnchor = True
.EscapeKey
.ShapeRange.Select
.HomeKey Unit:=wdStory
.Font.Name = "Arial"
If frmMain.optOptIn.Value = True Then
.Font.Size = 9
Else
.Font.Size = 10
End If
End With

Command For Starting A New Paragraph
Ive been away from VB for far too long and it seems all the little simple things I can no longer do.

I have a lot of text going into a window that is all together and need to make new paragraphs are certain places. So in other words...

txt2.text = "blahhhhhhhhhh raja maco non me me nahhhhhh (want to start a new paragraph here) blahhhhhhhhhhhhhh"

I just forget the small command for it...any help would be great!

Richtextbox - Paragraph Character
how can i make my richtextbox control put the text on a new line, instead of showing the paragraph character?

Deleting Lines From A Paragraph
for example this is my text


ergaerg55awerr
ergfaegr33aerfaewr
efegaag55aefagf
awefawef22eawfawef
agfagr22awerawer
aergerg55aeraewr

if this line has 55 in it then the whole line gets deleted...


this is what i got right now and obviously not working


Code:
Private Sub Command4_Click()
For y = 1 To Len(para)
If Asc(Mid(para, y, 1)) = 13 Then
en1 = y
End If
If Mid(para, y, 3) = "88/" Then
del = True
End If
If Asc(Mid(para, y, 1)) = 13 And en1 <> y Then
en2 = y
If del = True Then
Mid(para, en1, en2 - en1) = ""
en1 = ""
en2 = ""
del = False
End If
End If

Next y
Text2.Text = para
End Sub


i want to delete the line with "88/"









second request:
i have this as text:

abc33wer
abc33awe
abc44wer
abc44awe
abc55wer
abc55awf

ther are repeats of abcXX, i want to keep one line and delete the second, is there a way to do that?'

this is what i got and its incomplete and it doest work


Code:
For y = 1 To Len(para)
If Asc(Mid(para, y, 1)) > 64 And Asc(Mid(para, y, 1)) < 123 Then
q = q + 1
ElseIf q > 1 And Asc(Mid(para, y, 1)) < 65 Or Asc(Mid(para, y, 1)) > 122 Then
tempsen = Mid(para, y - q, q)
Exit For
q = 0
If Asc(Mid(para, y, 1)) = 13 Then
If Asc(Mid(para, y, 1)) > 64 And Asc(Mid(para, y, 1)) < 123 Then
q = q + 1
ElseIf q > 1 And Asc(Mid(para, y, 1)) < 65 Or Asc(Mid(para, y, 1)) > 122 Then
tempsen2 = Mid(para, y - q, q)
If tempsen2 = tempsen1 Then

End If
Next y
Text2.Text = tempsen

Find Line #3 In Each Paragraph
if i have a notpad file and want to search it from thired line in each paragraph

and check if first word is 'SOLUTION' then extract some words and go to the next 'SOLUTION' and do the same thing

if first word is 'COMMENT' then take the whole line



(actually it's not a paragraph they are some groups of unrelated lines separated by empty line )

can anyone help..... PLEASE

Detect A New Paragraph In A Textbox
i'm messing around with a text analysising program for vb but can't figure out how to detect new paragrapghs, have thought of looking for ascii codes but not sure how to do this.

heres my example code for checking for fullstops

Case "."
strCurrentChar = "."

Select Case Left$(strPreviousChar, 1)
Case "A" To "Z", "a" To "z", " "
intCharCount = intCharCount + 1
intSentenceCount = intSentenceCount + 1
Case "", "."
intCharCount = intCharCount + 1
End Select

Help much appreciated.

Sentence, Paragraph Counting
Im making a small notepad type thing, and I want to know how to count the following things:


1) Count how many sectences there are in the rich text box
2) Count how many paragraphs there are

How Can I Store A Paragraph In A String?
Anoyne know how to do this?

That is, be able to store a paragraph like it looks into a strng, including all enters, etc..

The key to this involves the vbcode for allowing code to go on 2 lines..

EG: string = "Something blah blah blah " _
"more string"

but i dont know what the "_" is supposed to be..

anyon know?

Finding A String In A BIG Paragraph
Given this long paragraph, can anyone show me code to parse out the
Magna Carta ?

<p class=MsoNormal style='line-height:12.0pt;mso-hyphenate:none'><b>Magna Carta </b>
(June 15, 1215), known as the &quot;cornerstone of English liberty,&quot; was a
constitutional charter signed by King John I of England (December 24,
1167-October 18, 1216) in the meadow of Runnymeade, under pressure from the
English barons. This was the first time the absolute power of a king was limited
by law, guaranteeing certain rights to his subjects. Included in the provisions
were:</p>

Paragraph Auto Numbering?
Hi all,
Try and re-phrase this one again. When you write a paragraph in word you start with a number ie.

1. Then you write your text.

On pressing the return key it starts another paragraph.

1. Then you write your text.

2. Then you can write the next paragraph.

Anyone got an idea how I can acheive this?

Thanks

Spud

How To Find The Begining Of A Paragraph
how to find the begining of a paragraph ...?

Paragraph Numbering With WIN32API
Since VB doesn't have built-in function for applying numbering to paragraphs like SELBULLET does for bullets, is there a way to use WIN32API to simulate such a function?

Any suggestions will be appreciated.

Thanks

Column Break(2) To Particular Paragraph
Question:how to format a particular paragraph in column break (2)

Copyright 2005-08 www.BigResource.com, All rights reserved