get section name

J

john smith

I need to find a section number and get its name to store it in a variable.

Example:
1.1 Introduction

Need to find 1.1 and then store"introduction" into a variable.

Anyone know how to do that?

Thanks!
 
J

Jezebel

That's not a section name, it's a heading. How you extract it depends on how
it's marked. If it's the first level one heading in the document, iterate
the paragraphs and return the first with OutlineLevel = 1
 
J

Jean-Guy Marcil

john smith was telling us:
john smith nous racontait que :
I need to find a section number and get its name to store it in a
variable.
Example:
1.1 Introduction

Need to find 1.1 and then store"introduction" into a variable.

Anyone know how to do that?

Thanks!

You have posted elsewhere a question that was also referring to something
you call a "section".

From those two post I can conclude that they are not sections.
A section in word is the area of text delimited by sections breaks (Insert >
Breaks > Sections...)

What you are writing about here looks like a paragraph.

Now, is
1.1 Introduction
a paragraph with a style applied that includes numbering?

--
Salut!
_______________________________________
Jean-Guy Marcil - Word MVP
(e-mail address removed)
Word MVP site: http://www.word.mvps.org
 
J

john smith

Yeah, I'm sorry about my terms here. It is a paragraph with numbering
involved. I just want to get the name there after the number.

Would you know how to do that?

Thank you so much!
 
J

Jean-Guy Marcil

john smith was telling us:
john smith nous racontait que :
Yeah, I'm sorry about my terms here. It is a paragraph with numbering
involved. I just want to get the name there after the number.

Would you know how to do that?

When you use AutoNumbering, the number itself is not part of the paragraph
range, so you can use something like this (Which removes the ¶ from the
range):

Dim rgePara As Range
Dim strParaText As String

Set rgePara = Selection.Paragraphs(1).Range
With rgePara
.MoveEnd wdCharacter, -1
strParaText = .Text
End With

--
Salut!
_______________________________________
Jean-Guy Marcil - Word MVP
(e-mail address removed)
Word MVP site: http://www.word.mvps.org
 
J

john smith

Hi Jean,

Thanks for your help. Further, I'd like to find a particular numbering like
1.1 or 1.2 in TOC below Part II Test Cases
then get the name after the number.

For example in TOC:
Table Of Contents

Part I Background Information. 4

1 Overview of Feature or System under Test 4

2 Scope of Test 4

3 Assumptions and Constraints 4

4 Resources Requirements 5

4.1 Skill Requirements 5

4.2 Hardware Requirements 5

4.3 Software Requirements 5



Part II Test Cases 8

1 Add 8

2 Move 11

3 Copy 13

4 Shortcut 15



I want to find number 1 name(=Add), number 2 name(=Move) etc... and store it
in variable. Would you know how to do that?



Thanks
 
J

Jean-Guy Marcil

john smith was telling us:
john smith nous racontait que :
Hi Jean,

Thanks for your help. Further, I'd like to find a particular
numbering like 1.1 or 1.2 in TOC below Part II Test Cases
then get the name after the number.

For example in TOC:
Table Of Contents

Part I Background Information. 4

1 Overview of Feature or System under Test 4

2 Scope of Test 4

3 Assumptions and Constraints 4

4 Resources Requirements 5

4.1 Skill Requirements 5

4.2 Hardware Requirements 5

4.3 Software Requirements 5



Part II Test Cases 8

1 Add 8

2 Move 11

3 Copy 13

4 Shortcut 15



I want to find number 1 name(=Add), number 2 name(=Move) etc... and
store it in variable. Would you know how to do that?

Yes, I could, but it would take a fair amount of code.
Also, without knowing the logic involved, it is rather pointless to try to
write some code.

May I ask what is your purpose here?

Have you tried to code it yourself?

--
Salut!
_______________________________________
Jean-Guy Marcil - Word MVP
(e-mail address removed)
Word MVP site: http://www.word.mvps.org
 

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