Microsoft Office Forums

Go Back   Microsoft Office Forums > >

Reply
 
Thread Tools Display Modes
  #1  
Old 04-22-2009, 12:46 PM
caution5697 caution5697 is offline
Novice
Formatting Help
 
Join Date: Apr 2009
Posts: 2
caution5697 is on a distinguished road
Default Formatting Help

I am trying to format a book that I can put on my amazon kindle, but im having some formatting problems. The only real way to explain this problem is by seeing a picture



I need it all to look like the bottom part that is longer. The problem is that the type is already broken up into a column with specific line lengths. I need to make them all into one line essentially so that if i were to resize the page, they would resize. Sorry if this is confusing, I can clarify if it doesn't make any sense to you guys
Thanks in Advance
Andrew
Attached Images
File Type: jpg Picture 3.jpg (44.1 KB, 25 views)
Reply With Quote
  #2  
Old 04-22-2009, 01:41 PM
Bird_FAT's Avatar
Bird_FAT Bird_FAT is offline Formatting Help Formatting Help Office 2007
Expert
 
Join Date: Apr 2009
Location: South East
Posts: 271
Bird_FAT is on a distinguished road
Default paragraph markers

In the find and replace, under 'more > special' you can find the paragraph marker (^p). With a bit of fiddling, you will find that that is all you need!

Ctrl+H will bring up the Find and Replace menu

First Find [^p^p]
Replace [**]

then Find [^p]
Replace [ ] - 1 space

finally Find [**]
Replace [^p^p]

This then takes all the paragraphs (1 marker at the end of the paragraph, and one clear space in between) and turns them into another symbol [**], then it takes all the paragraph markers that are at the end of each line and replaces them with a space - this gets all the lines back together, finally replacing all the paragraph breaks.

This is only a rough idea, whether you need to tweak it is dependent on your file.

If you record this as a macro in Normal.dot, the you can run it again later, when you want to format another document!
Reply With Quote
  #3  
Old 04-22-2009, 02:03 PM
caution5697 caution5697 is offline
Novice
Formatting Help
 
Join Date: Apr 2009
Posts: 2
caution5697 is on a distinguished road
Default

wow, thanks for the fast response time.
This is almost exactly what I, i tried it out, and it worked almost perfectly. What happened was i ran it on the entire document, which is several hundred pages long, and it compressed it into one large paragraph. This is an improvement over what i had before, but not the paragraphs that are supposed to exist in the book are gone. Is there any way that I can have word only do that command to paragraphs that start with a lowercase letter? this would work for 99% of the time because formal paragraphs start with an uppercase letter, and there broken paragraphs do not unless the word that appears first in a proper noun or something capitalized. That tiny margin for error really doesnt make any difference to me. If you know some way that i can make that happen, I would be so happy!
Thanks Again!
Andrew
Reply With Quote
  #4  
Old 04-22-2009, 11:53 PM
Bird_FAT's Avatar
Bird_FAT Bird_FAT is offline Formatting Help Formatting Help Office 2007
Expert
 
Join Date: Apr 2009
Location: South East
Posts: 271
Bird_FAT is on a distinguished road
Default Quickest way...

I would say the quickest, and probably most accurate, way would be to run through the document and add your [**] symbols yourself, then just Find and Replace the paragraph markers. - I know that this isn't the ideal solution, but having done the same thing that you are aiming to do, and having done it a million and one times, I just found it the most accurate!

It IS possible to write some VBA code to do what you want - BUT, it WON'T be anywhere near as accurate. For example, you asked about sorting it by paragraph - the problem is, your document has a paragraph marker at the end of every line, oops!

How about adapting your search string and turning it into a VBA code string:

Code:
Sub Find_and_Replace_Loop()

' Code String Written by Bird - 2009
' This macro will find and replace
' a) all full stops, question marks and exclamation marks followed by double paragraph markers
' b) 2 paragraph markers together - this is repeated in case there are 3 or four together
' c) all single paragraph markers, into spaces
' d) finally putting paragraph markers back.


    Selection.Find.ClearFormatting
    With Selection.Find
        .Text = ".^p^p"
        .Replacement.Text = ".**"
        .Forward = True
        .Wrap = wdFindContinue
        .Format = False
        .MatchCase = False
        .MatchWholeWord = False
        .MatchWildcards = False
        .MatchSoundsLike = False
        .MatchAllWordForms = False
    End With
    With Selection.Find
        .Text = "?^p^p"
        .Replacement.Text = "?**"
        .Forward = True
        .Wrap = wdFindContinue
        .Format = False
        .MatchCase = False
        .MatchWholeWord = False
        .MatchWildcards = False
        .MatchSoundsLike = False
        .MatchAllWordForms = False
    End With
    With Selection.Find
        .Text = "!^p^p"
        .Replacement.Text = "!**"
        .Forward = True
        .Wrap = wdFindContinue
        .Format = False
        .MatchCase = False
        .MatchWholeWord = False
        .MatchWildcards = False
        .MatchSoundsLike = False
        .MatchAllWordForms = False
    End With
    With Selection.Find
        .Text = "^p^p"
        .Replacement.Text = "^p"
        .Forward = True
        .Wrap = wdFindContinue
        .Format = False
        .MatchCase = False
        .MatchWholeWord = False
        .MatchWildcards = False
        .MatchSoundsLike = False
        .MatchAllWordForms = False
    End With
    With Selection.Find
        .Text = "^p^p"
        .Replacement.Text = "^p"
        .Forward = True
        .Wrap = wdFindContinue
        .Format = False
        .MatchCase = False
        .MatchWholeWord = False
        .MatchWildcards = False
        .MatchSoundsLike = False
        .MatchAllWordForms = False
    End With
    With Selection.Find
        .Text = "^p^p"
        .Replacement.Text = "^p"
        .Forward = True
        .Wrap = wdFindContinue
        .Format = False
        .MatchCase = False
        .MatchWholeWord = False
        .MatchWildcards = False
        .MatchSoundsLike = False
        .MatchAllWordForms = False
    End With
    With Selection.Find
        .Text = "^p"
        .Replacement.Text = " "
        .Forward = True
        .Wrap = wdFindContinue
        .Format = False
        .MatchCase = False
        .MatchWholeWord = False
        .MatchWildcards = False
        .MatchSoundsLike = False
        .MatchAllWordForms = False
    End With
    With Selection.Find
        .Text = "**"
        .Replacement.Text = "^p"
        .Forward = True
        .Wrap = wdFindContinue
        .Format = False
        .MatchCase = False
        .MatchWholeWord = False
        .MatchWildcards = False
        .MatchSoundsLike = False
        .MatchAllWordForms = False
    End With
        Loop
End Sub
This is just an example of what you can do. I have expanded the double paragraph marker string to start with [. ! ?] as these would be the markers at the end of a complete sentence in a paragraph.

Have a go at it and see if you can adapt it to your needs.

To add the VBA code:

  • Open Word
  • Use Alt+F11 to open your VBA window
  • In the Left hand 'tree' window look for Normal and open the Modules
  • If there is no Module, use the Insert menu to add one
  • Once you have a Module, double-click it to open
  • Copy and Paste the above code
By putting this in Normal you are able to use this macro in any document.
To run it - (2003) Tools > Macro > Macros (or Alt+F8)
(2007) View > Macros > View Macros (or Alt+F8)


Have fun with the code - play around with it to suit your needs.
Reply With Quote
Reply



Similar Threads
Thread Thread Starter Forum Replies Last Post
Formatting Help Cell formatting Niko Excel 5 04-23-2009 12:05 AM
Table of Contents Formatting Rick5150 Word 1 03-16-2009 11:10 AM
Re Formatting Columns? erikjen Word 0 02-16-2009 12:25 AM
Word Formatting Peter B. Word 5 05-10-2006 08:13 AM
Different page number formatting. gerrie Word 0 04-15-2006 07:31 PM

Other Forums: Access Forums

All times are GMT -7. The time now is 09:18 AM.


Powered by vBulletin® Version 3.8.11
Copyright ©2000 - 2024, vBulletin Solutions Inc.
Search Engine Optimisation provided by DragonByte SEO (Lite) - vBulletin Mods & Addons Copyright © 2024 DragonByte Technologies Ltd.
MSOfficeForums.com is not affiliated with Microsoft