sending a "special" line feed through code??

M

Mr. T.

Hi,

i've got a word document with a numbered list that i'm filling up from
within my access code. So far, no problem.

Now in a numbered list (or a bulleted list for that matter) in word, if you
press the enter key, you get a new list item (a new number or bullet). If
you want the new line to resort under the same number, you type SHIFT+ENTER
and that's it.

Now my question is how i can pass that through by VBA code? If i send VbCrLf
or VbCr or VbLf or chr(10) or chr(13) my text allways get put as a new item
in the list. Basically what i'm getting is

1. text
2. text
3. text
4. text
etc...

when what i really want is

1. text
text
2. text
3. text
text
etc...

So my (simple?) question is: what do i need to send as code after my line so
that it doesn't start a new item in the list?

Regards & thx in advance for your replies!

Thomas
 
J

Jezebel

You're confusing two issues here. The style of a subsequent paragraph is
determined by the style definition ('Style for following paragraph" -- for
list styles the default is to continue in the same style). It's only
indirectly a function of the keypress. If you're working from VBA, the
better approach is to set the paragraph style explicitly.

In general you don't get very far in VBA trying to work with keycodes as
such. You *can* do it, but it's a clumsy way to proceed. Since Word
"interprets" the keycode in order to produce a specific formatting effect,
from VBA it's better to go directly to the effect you want, than to simulate
the keystrokes that Word will (inshallah!) interpret to produce that effect.
 
M

Mr. T.

Hi,

thx but even then, if i would have a line feed in the paragraph, it would
generate a new item in my list, wouldn't it?

What i'm trying to achieve is the following list:

1. Application Number: 123456789
Filing Date: 01/01/2004
Status: Registered
2. Application Number: 98765
Filing Date: 01/02/2004
etc ...

But in my code, after application number, i put a chr(13) to let it proceed
to the next line. Now if i do that and then apply the style, it would put 2.
before Filing Date, and that's just what i'm trying to avoid. Or maybe i'm
missing something rather obvious here?

Regards,

Thomas
 
J

Jezebel

You're thinking about this the wrong way. You don't 'send' keystrokes from
VBA to Word (as I said, you *can* but it's a bad way to write code). Better
is to use commands like InsertBefore, InsertAfter, InsertParagraph (etc) as
needed, and format the paragraphs to the style you want.

In your sample, depending on what you want to achieve, either use a line
break between the Application number and the Filing date (same paragraph, no
change of style), or define a different style that is indented but not
numbered.
 
J

Jonathan West

You need to insert a line feed character, which is vbLf or Chr(10), instead
of a paragraph mark, which is vbCr or Chr(13)
 
M

Mr. T.

Hi,

i do that, but still, even with chr(10) it gives a new item in my list in
stead of putting it under the same item.

Regards,

Thomas
 
M

Mr. T.

Hi,
In your sample, depending on what you want to achieve, either use a line
break between the Application number and the Filing date (same paragraph, no
change of style), or define a different style that is indented but not
numbered.
if i do that, i.e. use a line break, it still makes a new item in my list.

So in fact that gets me back to my initial question: what do i need to do
after i put my data in the document so that i'm in fact on a new line but
that the list doesn't jump to a new item (but perhaps i didn't phrase the
question quite correctly ...).

what i'm getting now is

1.app number
2.filing date
3.status
4.app number
5.filing date

etc...

whereas what i want to get is

1.app number
filing date
status
2.app number
filing date
etc...

Regards,

Thomas
 
M

Mr. T.

to talk more concrete, below you find my testcode:

Set opara3 = odoc.Content.Paragraphs.Add(odoc.Bookmarks("\endofdoc").range)
opara3.range.Text = "first text:"
opara3.outdent
opara3.Format.SpaceAfter = 10
opara3.range.InsertParagraphAfter
Set opara3 = Nothing

Set opara3 = odoc.Content.Paragraphs.Add(odoc.Bookmarks("\endofdoc").range)
opara3.range.Text = "second text first line" & vbLf & "second text second
line"
opara3.indent
opara3.Format.SpaceAfter = 10
opara3.range.InsertParagraphAfter
Set opara3 = Nothing

Set opara3 = odoc.Content.Paragraphs.Add(odoc.Bookmarks("\endofdoc").range)
opara3.range.Text = "third text"
opara3.outdent
opara3.Format.SpaceAfter = 10
opara3.range.InsertParagraphAfter
Set opara3 = Nothing

Set opara3 = odoc.Content.Paragraphs.Add(odoc.Bookmarks("\endofdoc").range)
opara3.range.Text = "fourth text"
opara3.outdent
opara3.Format.SpaceAfter = 10
opara3.range.InsertParagraphAfter
Set opara3 = Nothing

when i run this, i get

forst text
second text first line
second text second line
third text
fourth text

so the "second text first line" is not indented as it should be. It should
come on the same level as "second text second line". How to achieve that is
really all i'm looking for ...

Regards & thx 4 your patience

Thomas
 
C

Cindy M -WordMVP-

Hi Mr.,
i do that, but still, even with chr(10) it gives a new item in my list in
stead of putting it under the same item.
Jonathan had the wrong number at the tip of his fingers. Try Chr$(11) :)

Cindy Meister
INTER-Solutions, Switzerland
http://homepage.swissonline.ch/cindymeister (last update Sep 30 2003)
http://www.word.mvps.org

This reply is posted in the Newsgroup; please post any follow question or
reply in the newsgroup and not by e-mail :)
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top