+ Reply to Thread
Results 1 to 3 of 3

This is funny!!! Helpful Ms word vba

  1. #1
    Registered User
    Join Date
    10-16-2005
    Posts
    11

    This is funny!!! Helpful Ms word vba

    I'm kinda new to vba. This took me lots of hours to make/I'm confused. I need clarification help.

    Goal:
    Find paragraph with specific level format (1/2 for example) and add space to beginning of each selection

    The functions I need are already created, except I have some problems:
    For my function to work throughout, I have to type something in a msgbox for my script to go forward for each manipulation.

    Is there anyway to make it run smoothly, and then to have a msgbox to tell me that my script was done working its function?



    Sub macccta()
    Dim sResponse As String

    Do

    sResponse = InputBox(Prompt:="Type no to exit,Baby", _
    Title:="", Default:="")
    If sResponse = "no" Then Exit Sub Else 'this is convenient because I can just type "no" to exit a nasty loop; this keeps on looping... where should it place?


    If sResponse > "" Then '<--what does this single statement means, especially the >? I think its always making me need to input anything to make the rest of the script work

    Selection.HomeKey Unit:=wdStory 'start in the beginning of doc

    Selection.Find.ClearFormatting
    With Selection.Find
    'we are finding heading 2
    .ParagraphFormat.OutlineLevel = wdOutlineLevel2



    Do While .Execute

    Selection.InsertBefore " "


    'selection is converted as body text, because if not, the script keeps on looping because I dont know what I'm missing to make it stop
    Selection.ParagraphFormat.OutlineLevel = wdOutlineLevelBodyText

    Loop
    End With

    End If
    Loop While sResponse <> ""
    MsgBox "done"


    End Sub

    This script would be very useful for those who wants to copy all the selection after and paste it into Freemind (a great mindmapping free software!), which recognizes 'spaces' as heading levels.

    Thx you!!!! Plz help!
    Last edited by Ambrosia; 03-20-2006 at 11:41 PM.

  2. #2
    Dave Peterson
    Guest

    Re: This is funny!!! Helpful Ms word vba

    You may get much better answers in one of the newsgroups dedicated to
    MSWord--not Excel.

    Ambrosia wrote:
    >
    > I'm kinda new to vba. This took me lots of hours to make/I'm confused. I
    > need clarification help.
    >
    > Goal:
    > Find paragraph with specific level format (1/2 for example) and add
    > space to beginning of each selection
    >
    > The functions I need are already created, except I have some problems:
    > For my function to work throughout, I have to type something in a
    > msgbox for my script to go forward for each manipulation.
    >
    > Is there anyway to make it run smoothly, and then to have a msgbox to
    > tell me that my script was done working its function?
    >
    > Sub macccta()
    > Dim sResponse As String
    >
    > Do
    >
    > sResponse = InputBox(Prompt:="Type no to exit,Baby", _
    > Title:="", Default:="")
    > If sResponse = "no" Then Exit Sub Else 'this is
    > convenient because I can just type "no" to exit a nasty loop; this
    > keeps on looping... where should it place?
    >
    > If sResponse > "" Then '<--what does this single
    > statement means, especially the >? I think its always making me need
    > to input anything to make the rest of the script work
    >
    > Selection.HomeKey Unit:=wdStory 'start in the beginning of doc
    >
    > Selection.Find.ClearFormatting
    > With Selection.Find
    > 'we are finding heading 2
    > ParagraphFormat.OutlineLevel = wdOutlineLevel2
    >
    > Do While .Execute
    >
    > Selection.InsertBefore " "
    >
    > 'election is converted as body text, because if not, the script keeps
    > on looping because I dont know what I'm missing to make it stop
    > Selection.ParagraphFormat.OutlineLevel = wdOutlineLevelBodyText
    >
    > Loop
    > End With
    >
    > End If
    > Loop While sResponse <> ""
    > MsgBox "done"
    >
    > End Sub
    >
    > This script would be very useful for people who wants to copy all the
    > selection after and paste it into Freemind (a great mindmapping free
    > software!), which recognizes 'spaces' as heading levels.
    >
    > Thx you!!!! Plz help!
    >
    > --
    > Ambrosia
    > ------------------------------------------------------------------------
    > Ambrosia's Profile: http://www.excelforum.com/member.php...o&userid=28146
    > View this thread: http://www.excelforum.com/showthread...hreadid=524664


    --

    Dave Peterson

  3. #3
    Registered User
    Join Date
    10-16-2005
    Posts
    11
    Lol, I'll answer me own question! Sorry I asked in excel a Word question...
    Sub sodsaS()
    With ActiveDocument.Content.Find
    .ClearFormatting
    .ParagraphFormat.OutlineLevel = wdOutlineLevel2 '---change numbers according to outline level
    Do While .Execute(FindText:="", Forward:=True, _
    Format:=True) = True
    With .Parent
    .StartOf Unit:=wdParagraph, Extend:=wdMove
    .InsertAfter "#" '-----is what gets inserted in the beginning!
    .Move Unit:=wdParagraph, Count:=1
    End With
    Loop
    End With
    End Sub


    Good luck people! lol

+ Reply to Thread

Thread Information

Users Browsing this Thread

There are currently 1 users browsing this thread. (0 members and 1 guests)

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts

Search Engine Friendly URLs by vBSEO 3.6.0 RC 1