Palimpsest  

Go Back   Palimpsest > Palimpsest Groups > The Book Group Discussions


Reply
 
Thread Tools Display Modes
Old 21st Oct 2005, 15:21   #11
Stewart
Once known as Blixa
takes it to extremes
 
Stewart's Avatar
 
Join Date: 26 May 2005
Location: Glasgow
Posts: 6,884
Send a message via MSN to Stewart
Default Re: Bk 19: The First Men in the Moon/The Sleeper Awakes - H.G. Wells

Okay, have managed to do it. The code below may look like gobbledegook to most but it works and that's the important thing.

It's not perfect, however, and some lines get merged but that's easily fixable manually.
  1. Open up a blank Word Document;
  2. Copy your chosen text into it.
  3. In the menu select Tools -> Macro -> Visual Basic Editor
  4. You should see the Project Explorer on the left of the screen. It's a tree-like hierarchy listing all the components of the session of Word. Documents, Projects, etc. If it's not there then press Crtl + R to bring it up;
  5. Click once on This Document in the appropriate project i.e. the name of your Word document
  6. In the menu select Insert -> Module
  7. You will be presented with a new module with the words Option Explixit at the top. Copy the code below into the module after Option Explicit. If Option Explicit is not there then write that at the top of the module.
  8. Close the Visual Basic editor window and return to your document
  9. In the menu select Tools -> Macro -> Macros and select the new macro entitled FixMyDocument
  10. Click the Run button and wait about ten seconds while it fixes your document.

Code:
    Const cstrTitle1 As String = "Operation Failed"
    Const cstrTitle2 As String = "Operation Successful"
 
    Const cstrMessage1 As String = "Unable to populate search and replace terms."
    Const cstrMessage2 As String = "Unable to perform search and replace operation."
    Const cstrMessage3 As String = "Unable to correctly justify text."
    Const cstrMessage4 As String = "The document has been successfully formatted."
 
    Dim strSources(1 To 3) As String
    Dim strReplaces(1 To 3) As String
 
Public Sub FixMyDocument()
    Dim lngCounter As Long
    ' Populate arrays with values
    If Not fGetValues Then
        MsgBox cstrMessage1, vbExclamation, cstrTitle1
        Exit Sub ' FixMyDocument
    End If
 
    ' Perform search and replace three times
    For lngCounter = 1 To 3
        If Not fCorrectText(lngCounter) Then
            MsgBox cstrMessage2, vbExclamation, cstrTitle1
            Exit Sub ' FixMyDocument
        End If
    Next lngCounter
 
    ' Justify the text
    If Not fJustifyText Then
        MsgBox cstrMessage3, vbExclamation, cstrTitle1
        Exit Sub ' FixMyDocument
    End If
 
    ' Display success message
    MsgBox cstrMessage4, vbExclamation, cstrTitle2
End Sub ' FixMyDocument
 
Private Function fGetValues() As Boolean
    On Error GoTo Err_fGetValues
 
    ' Populate arrays for looping
    strSources(1) = vbCr
    strSources(2) = ".||"
    strSources(3) = "||"
    strReplaces(1) = "||"
    strReplaces(2) = "." & vbCr & vbCr
    strReplaces(3) = vbNullString
 
    fGetValues = True ' Function was a success
 
    Exit Function ' fGetValues
 
Err_fGetValues:
    fGetValues = False ' Function failed
 
End Function ' fGetValues
 
Private Function fCorrectText(ByVal lngCounter As Long) As Boolean
    On Error GoTo Err_fCorrectText
    Selection.Find.ClearFormatting
    Selection.Find.Replacement.ClearFormatting
 
    With Selection.Find
        .Text = strSources(lngCounter)
        .Replacement.Text = strReplaces(lngCounter)
        .Forward = True
        .Wrap = wdFindContinue
        .Format = False
        .MatchCase = False
        .MatchWholeWord = False
        .MatchWildcards = False
        .MatchSoundsLike = False
        .MatchAllWordForms = False
    End With
 
    Selection.Find.Execute Replace:=wdReplaceAll
    fCorrectText = True
 
    Exit Function ' fCorrectText
 
Err_fCorrectText:
    fCorrectText = False
 
End Function ' fCorrectText
 
Private Function fJustifyText()
    On Error GoTo Err_fJustifyText
 
    Selection.WholeStory
    Selection.ParagraphFormat.Alignment = wdAlignParagraphJustify
 
    fJustifyText = True
 
    Exit Function
 
Err_fJustifyText:
    fJustifyText = False
 
End Function ' fJustifyText


I might look into developing this a little further as a Word add-in meaning that you can just "click" the code into place without knowing what you are doing and just select Fix Document, or whatever, from the Tools menu.
__________________
Reading: Concrete Island, J.G. Ballard| flickr | blog | world lit | beer

Last edited by Stewart; 21st Oct 2005 at 15:29.
Stewart is offline   Reply With Quote
Old 21st Oct 2005, 16:19   #12
Jerkass
Palimpsestarian
eats too much cheese
 
Jerkass's Avatar
 
Join Date: 16 Dec 2003
Location: USA
Posts: 1,288
Default Re: Bk 19: The First Men in the Moon/The Sleeper Awakes - H.G. Wells

After that latest round of the Blixatech Expo '05, I'll answer Wavid's question: I'm reading The First Men in the Moon. I was told we could choose one or the other, so I did.

Still trying to get through Everything Is Illuminated at a pace of three pages per week, and with NoNoWriMoSest coming up, I'll hope to complete it in November at some point.
__________________
"I learned never to drink anything out of a jar labeled 'w-i-s-k-i.'"
Jerkass is offline   Reply With Quote
Old 22nd Oct 2005, 18:12   #13
pandop
Palimpsestarian
eats too much cheese
 
pandop's Avatar
 
Join Date: 27 Jun 2003
Location: Leeds, West Yorkshire
Posts: 1,319
Default Re: Bk 19: The First Men in the Moon/The Sleeper Awakes - H.G. Wells

I want to read both, but I can't even think about it until I have my assignments in <sigh>
This module is not going well

Hazel
__________________
The brain is a wonderful organ. It starts working the moment you get up in the morning, and doesn't stop until you get into the office

pandop is offline   Reply With Quote
Old 25th Oct 2005, 10:23   #14
carfilhiot
Junior Palimpsestarian
is starting to settle in
 
carfilhiot's Avatar
 
Join Date: 20 Jun 2005
Location: Somewhere in the Mediterranean
Posts: 31
Default Re: Bk 19: The First Men in the Moon/The Sleeper Awakes - H.G. Wells

I have put up on my website an HTML version of The First Men in the Moon at http://www.carfilhiot.co.uk/texts/1013.htm

The Sleeper Awakes is available at http://www.carfilhiot.co.uk/texts/12163-8.htm

Each is about 500Kb in length, so dial-up users may experience a delay.

You can save it locally by using File->Save As -> so you only have the download once.

Last edited by carfilhiot; 25th Oct 2005 at 10:28.
carfilhiot is offline   Reply With Quote
Old 25th Oct 2005, 10:31   #15
carfilhiot
Junior Palimpsestarian
is starting to settle in
 
carfilhiot's Avatar
 
Join Date: 20 Jun 2005
Location: Somewhere in the Mediterranean
Posts: 31
Default Re: Bk 19: The First Men in the Moon/The Sleeper Awakes - H.G. Wells

I have used GutenMark, a free utility that is rather hard to use if you are a Windows user (it's a command-line utility). I find it to be competent at rendering Gutenberg text into the more friendly HTML. Frankly, I feel I can afford to ignore the few blemishes because it's FREE!
carfilhiot is offline   Reply With Quote
Old 25th Oct 2005, 20:58   #16
Jerkass
Palimpsestarian
eats too much cheese
 
Jerkass's Avatar
 
Join Date: 16 Dec 2003
Location: USA
Posts: 1,288
Default Re: Bk 19: The First Men in the Moon/The Sleeper Awakes - H.G. Wells

I'm about sixty pages into The First Men in the Moon now...and, you know, you people might be on to something with this Wells character.

Yes, that's right--recall that I'm the person who finally was shocked into beginning to read again after a 15-year hiatus when I realized I always had considered myself a fan of Dickens, but HAD NEVER READ ANY OF HIS WORK--this is my first Wells.

I can't wait for him to turn out his next book. Er...what's that?
__________________
"I learned never to drink anything out of a jar labeled 'w-i-s-k-i.'"
Jerkass is offline   Reply With Quote
Old 25th Oct 2005, 22:02   #17
John Self
Administrator
suffers from smallness of vision
 
John Self's Avatar
 
Join Date: 27 Jun 2003
Location: Belfast
Posts: 15,939
Default Re: Bk 19: The First Men in the Moon/The Sleeper Awakes - H.G. Wells

That's no shame, Jerkass - my first Wells was about six months ago. Ooer, though, it's getting close to November and it looks as though I'm going to be joining in the debate later than normal... Still, on the bright side, Wells wrote enough books that you could read nothing but his stuff from now till the day you die.
__________________
Reading Vasily Grossman, Life and Fate | Asylum | Book List
John Self is offline   Reply With Quote
Old 25th Oct 2005, 23:10   #18
JunkMonkey
Senior Palimpsester
should be ashamed
 
JunkMonkey's Avatar
 
Join Date: 19 Oct 2005
Location: Highlands of Scotland
Posts: 2,692
Default Re: Bk 19: The First Men in the Moon/The Sleeper Awakes - H.G. Wells

Quote:
Originally Posted by Wavid
I am looking into reading the Project Gutenberg versions for free. The problem with them is that they are provided in ASCII text format, with hard line breaks, so that when you paste it into a word processor to reduce the font size and make it more readable, the text is completely buggered up.
Apart from the odd hiccup Project Gutenberg's stuff wraps nicely in my Palm Pilot. Not the best way to read a book I know but as my copy is "somewhere in depths of my attic" it will have to do.

It'll be good to read it again. I was about 11 when I last read it - 35 years ago.
__________________
Blog |Read|Film|Swapit

There Are Not Seven Words In My Signature

Last edited by JunkMonkey; 25th Oct 2005 at 23:12.
JunkMonkey is offline   Reply With Quote
Old 1st Nov 2005, 6:10   #19
m.
Palimpsestarian
eats too much cheese
 
m.'s Avatar
 
Join Date: 22 Nov 2003
Location: Poland
Posts: 1,300
Default Re: Bk 19: The First Men in the Moon/The Sleeper Awakes - H.G. Wells

Sorry, I'll be late to this. I'm very slow with reading lately, and have three or four books already started so dont want to add another. But as soon as I finish Tess (I'm in the middle of it, precisely). I keep a copy near already, and The First Men it is.
__________________
Reading.
m. is offline   Reply With Quote
Old 1st Nov 2005, 8:40   #20
gil
Senior Palimpsester
has the freedom of Palimp City
 
gil's Avatar
 
Join Date: 21 May 2003
Location: Farnham, UK
Posts: 3,287
Default Re: Bk 19: The First Men in the Moon/The Sleeper Awakes - H.G. Wells

Yes, I'm going to be late, too.
gil is offline   Reply With Quote
Reply



Currently Active Users Viewing This Thread: 1 (0 members and 1 guests)
 
Thread Tools
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 On
HTML code is Off

Forum Jump

Similar Threads
Thread Thread Starter Forum Replies Last Post
Book Groups Wavid General Chat 43 13th Apr 2010 22:43
H.G. Wells Mike Book Reviews 24 28th Nov 2008 18:47


All times are GMT +1. The time now is 16:06.


Powered by vBulletin® Version 3.8.7
Copyright ©2000 - 2017, vBulletin Solutions, Inc.