#1   Report Post  
Posted to microsoft.public.word.docmanagement
 
Posts: n/a
Default Outline view loop

Hi,

So far I have managed to indivudually promote or demote a line, but I
cannot generalize zhis macro to the whole document ...

Sub MacroAdjust()
Dim StrWord As String 'text being analysed
Dim NPer As Long 'number of periods
Selection.EndKey Unit:=wdLine, Extend:=wdExtend
If InStr(Selection, ".") = 0 Then
Selection.Paragraphs.OutlinePromote
Else
StrWord = Left(Selection, InStr(Selection, " ") - 1)
NPer = UBound(Split(StrWord, ".")) - LBound(Split(StrWord, "."))
Select Case NPer
Case 2: Selection.Paragraphs.OutlineDemote
Case 3: Selection.Paragraphs.OutlineDemote
Selection.Paragraphs.OutlineDemote
End Select
End If
End Sub

Is there a way to loop through all the headings shown in the outline
view ?
Thanks in advance for your advice
Cheers
Carim

  #2   Report Post  
Posted to microsoft.public.word.docmanagement
Cindy M -WordMVP-
 
Posts: n/a
Default Outline view loop

So far I have managed to indivudually promote or demote a line, but I
cannot generalize zhis macro to the whole document ...

Sub MacroAdjust()
Dim StrWord As String 'text being analysed
Dim NPer As Long 'number of periods
Selection.EndKey Unit:=wdLine, Extend:=wdExtend
If InStr(Selection, ".") = 0 Then
Selection.Paragraphs.OutlinePromote
Else
StrWord = Left(Selection, InStr(Selection, " ") - 1)
NPer = UBound(Split(StrWord, ".")) - LBound(Split(StrWord, "."))
Select Case NPer
Case 2: Selection.Paragraphs.OutlineDemote
Case 3: Selection.Paragraphs.OutlineDemote
Selection.Paragraphs.OutlineDemote
End Select
End If
End Sub

Is there a way to loop through all the headings shown in the outline
view ?

Based only on what you show us, I'd say take a look at the
Selection.MoveDown method (related to the EndKey method you already
have in your code). This will return the actual number of units
(wdLine) that you moved. When it returns 0, you'd be at the end of the
visible text. Roughly, I'd set your code up like this (untested):

Do
'The code you have comes here
Loop While Selection.MoveDown(wdLine, 1) 0

Note that you may need to adjust selecting the entire line by first
moving the Selection to the front of the current line before extending
it across the line (something like Selection.HomeKey wdLine)

Note: the better place to get help with macros would be the word.vba
newsgroup. This is an end-user group, which means people with macro
knowledge may not happen by as often as in a vba group.

Cindy Meister
INTER-Solutions, Switzerland
http://homepage.swissonline.ch/cindymeister (last update Jun 8 2004)
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 :-)

  #3   Report Post  
Posted to microsoft.public.word.docmanagement
 
Posts: n/a
Default Outline view loop

Hello Cindy,

Thanks a lot for your piece of advice.

As far as the newsgroup is concerned, sorry for the inconvenience, I
will adjust right away.
As a matter of fact, it is my very first attempt in word.vba ... the
little I know comes from Excel.

Again thanks for your help
Best Regards
Carim

  #4   Report Post  
Posted to microsoft.public.word.docmanagement
Cindy M -WordMVP-
 
Posts: n/a
Default Outline view loop

As far as the newsgroup is concerned, sorry for the inconvenience, I
will adjust right away.

Not an inconvenience :-) Just that you're more likely to get help more
quickly in a word.vba group than here.

As a matter of fact, it is my very first attempt in word.vba

Good luck, then :-)! And one small tip, in that case: as in Excel, the
macro recorder is good for telling you the names of the objects you
need to work with. But the code is generally less than reliable
(SELECTION, like Selection or ActiveCell in Excel). If possible, it's
always a good idea to convert from Selection to using a Range object
(again, just like Excel). This is more easily said than done, I
realize :-) But something to think about. In the case of your
particular macro, Selection is fine because only a Selection can deal
with lines.

Cindy Meister
INTER-Solutions, Switzerland
http://homepage.swissonline.ch/cindymeister (last update Jun 8 2004)
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 :-)

  #5   Report Post  
Posted to microsoft.public.word.docmanagement
 
Posts: n/a
Default Outline view loop

Cindy,

May I thank you for your tips and advice. You are very kind, and your
encouragements are my best reward ... :-)
Indeed I badly need them, as I will soon have to understand the
"multiple-items-per-condition" challenge ..!!!

Thanks again and Best regards
Carim



  #6   Report Post  
Posted to microsoft.public.word.docmanagement
Cindy M -WordMVP-
 
Posts: n/a
Default Outline view loop

Indeed I badly need them, as I will soon have to understand the
"multiple-items-per-condition" challenge ..!!!

ouch (Personally, I consider it fun, but I've been accused of
having an odd sense of humour.)

There's a discussion on my website, in case you haven't come
across it yet, with links to sample files. If the DATABASE field
approach meets your needs, it's by far the easiest to work with.

If you need the more sophisticated, coded approach the
WdAcc97.zip file can give you some basics. Apply these to using
an ADO connection in order to pull the data from Excel. Should be
(relatively) easy :-)

Cindy Meister
INTER-Solutions, Switzerland
http://homepage.swissonline.ch/cindymeister (last update Jun 8
2004)
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 :-)

Reply
Thread Tools
Display Modes

Posting Rules

Smilies are On
[IMG] code is On
HTML code is Off

Forum Jump

Similar Threads
Thread Thread Starter Forum Replies Last Post
Right margin in Outline View Stefan4321 Page Layout 2 February 23rd 09 11:56 PM
Integrate Outline View with outline number lists msft_suggestor Page Layout 2 December 4th 05 10:50 PM
Printing in Outline View lolup Microsoft Word Help 2 November 29th 05 02:58 PM
Outline view and automatically update Mkate Microsoft Word Help 0 November 29th 05 02:53 AM
Apostophies do not appear in any view except outline view? Barbara Page Layout 1 August 20th 05 10:25 AM


All times are GMT +1. The time now is 05:52 AM.

Copyright ©2000 - 2025, Jelsoft Enterprises Ltd.
Copyright ©2004-2025 Microsoft Office Word Forum - WordBanter.
The comments are property of their posters.
 

About Us

"It's about Microsoft Word"