Wrox Programmer Forums

Need to download code?

View our list of code downloads.

Go Back   Wrox Programmer Forums > Microsoft Office > Other Office > Word VBA
Password Reminder
Register
| FAQ | Members List | Calendar | Search | Today's Posts | Mark Forums Read
Word VBA Discuss using VBA to program Word.
Welcome to the p2p.wrox.com Forums.

You are currently viewing the Word VBA section of the Wrox Programmer to Programmer discussions. This is a community of tens of thousands of software programmers and website developers including Wrox book authors and readers. As a guest, you can read any forum posting. By joining today you can post your own programming questions, respond to other developers’ questions, and eliminate the ads that are displayed to guests. Registration is fast, simple and absolutely free .
DRM-free e-books 300x50
Reply
 
Thread Tools Search this Thread Display Modes
  #1 (permalink)  
Old March 22nd, 2006, 03:58 AM
Registered User
 
Join Date: Mar 2006
Location: , , .
Posts: 4
Thanks: 0
Thanked 0 Times in 0 Posts
Default Almost finished helpful code--funny

Hello
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 or 2 for example) and add space to beginning of each paragrap 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 'paragraph level search



Do While .Execute

Selection.InsertBefore " " 'add a space!


'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--- down here

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!


Reply With Quote
  #2 (permalink)  
Old March 24th, 2006, 02:52 PM
Registered User
 
Join Date: Mar 2006
Location: , , .
Posts: 4
Thanks: 0
Thanked 0 Times in 0 Posts
Default

LOL!!! I'll answer my own question!
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 And I found this solution using VBa help! so much simpler
Reply With Quote
  #3 (permalink)  
Old March 27th, 2006, 09:21 PM
Registered User
 
Join Date: Mar 2006
Location: Sydney, NSW, Australia.
Posts: 7
Thanks: 0
Thanked 0 Times in 0 Posts
Default

LOL
This is Word VBA forum
LOL
Reply With Quote
Reply


Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off
Trackbacks are Off
Pingbacks are On
Refbacks are Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
E-mail notification when backup finished??? RinoDM SQL Server 2005 2 April 26th, 2007 10:42 AM
Funny date return needelp Access VBA 3 September 19th, 2006 11:37 PM
User-Level Security Wizard acting funny Bob Bedell Access 1 January 7th, 2006 02:53 AM
funny results.... richjo100 XSLT 3 September 27th, 2004 05:38 AM



All times are GMT -4. The time now is 01:07 PM.


Powered by vBulletin®
Copyright ©2000 - 2019, Jelsoft Enterprises Ltd.
© 2013 John Wiley & Sons, Inc.