Friday, November 15, 2013

Word macro auto chapter renumbered

Chapter Renumberer Word Macro


About how the Macro works

I wrote this for me and how I write, and I identify my chapters by
Manual page break
[Chapter #]

If you don't (nobody but me does) don't panic, you can still use this to automatically renumber your chapters just fine.

All you do is record a macro, have word find your manual page breaks, arrow over, and insert the [ before the word Chapter and ] after the number. Easy. Last thing I do just before publishing is delete all the [], or leave them (no big).

Enjoy.


'
Sub ChaptersRenumberer()
' [Chapter]
' This renumbers chapters and makes them uniform
' Bold, underlined, centered
'
Selection.Find.ClearFormatting
Selection.Find.Replacement.ClearFormatting
bLd = InputBox("Chapters are anything inside []" + Chr(13) + Chr(13) + _
"B for Bold" + Chr(13) + _
"U for Underline" + Chr(13) + _
"R to renumber Chapters" + Chr(13) + _
"C to Center Chapters" + Chr(13) + _
"S to Center STARS" + Chr(13) + _
" or X to exit this", "Bold/Underline Chapters", "BC")
If Len(bLd) = 0 Or Len(bLd) > 5 Then Exit Sub
If bLd = "x" Or bLd = "X" Then Exit Sub
RenumberThem = False
BoldThem = False
UnderlineThem = False
CenterThem = False
StarsCenter = False
For e = 1 To Len(bLd)
s = Mid(bLd, e, 1)
If s = "C" Or s = "c" Then CenterThem = True
If s = "R" Or s = "r" Then RenumberThem = True
If s = "U" Or s = "u" Then UnderlineThem = True
If s = "S" Or s = "s" Then StarsCenter = True
If s = "B" Or s = "b" Then BoldThem = True
Next e
aa = Selection.End
Selection.HomeKey Unit:=wdStory
oldText = Selection.Find.Text
'Ch = 2
Ch = InputBox("First Chapter number", , 2)
10:
With Selection.Find '===========================
.Text = "[" 'Here is what you'd want to modify
.Forward = True 'To help it identify your Chapters
.Execute 'mine start with [
End With
s = Selection.End
Selection.MoveRight
With Selection.Find
.Text = "]" 'and end with ]
.Forward = True
.Execute
End With '=============================
If Selection.Find.Found = False Then GoTo 30
e = Selection.End
If Abs(ek - e) < 900 Then
Ch = Val(Left(Right(ActiveDocument.Range(s, e), 3), 2))
Ch = InputBox("An error has been called" + Chr(13) + _
"X to abort" + Chr(13) + _
"Enter a number and it'll renumber starting there", , Ch)
If Ch = "x" Or Ch = "X" Then GoTo 30
End If
'GoTo 30
ActiveDocument.Range(s - 1, e).Select
If RenumberThem Then
If Left(Selection.Text, 2) = "[C" _
Or Left(Selection.Text, 2) = "[c" Then _
Selection.Text = "[Chapter" + Str(Ch) + "]"
End If
If UnderlineThem Then
Selection.Font.Underline = wdUnderlineSingle
Else
Selection.Font.Underline = wdUnderlineNone
End If
If BoldThem Then
Selection.Font.Bold = True
Else
Selection.Font.Bold = False
End If
If CenterThem Then Selection.ParagraphFormat.Alignment = wdAlignParagraphCenter
'
Selection.MoveDown
Ch = Ch + 1
If Ch > 200 Then GoTo 30
GoTo 10
'
30:
If StarsCenter = True Then Call CenterStars
Selection.End = aa
Selection.Start = aa
Selection.Find.Text = oldText
End Sub
'
'--------------------------------------------------------------------------------------

Tuesday, November 12, 2013

Monday, October 28, 2013

Winter blues cure

Time to switch to winter lights. These halogen bulbs (just one in the room) are full spectrum and alleviate my "winter blues" . It's not on the label, just a home remedy that seems to work for me. Just has to have halogen on the label.

Sunday, October 27, 2013

KDP tips for slimming down your download fees

Found my old notes on how to reduce the size of Kindle Files by manually editing the HTML, they might be useful to you and it's not all that hard to do, even though manually editing HTML sounds very intimidating. It should be noted that my version of Word is as old as my 2003 Laptop (Win XP, Word 2k?), so newer versions might act a little different.

Step 1> Save your DOC as a WEB page (.HTM). File/SaveAsWeb
Close Word. Make sure it isn't XML, this only applies to files ending in HTM.

Check where you saved the Web file. It should be Name.HTM AND, if you have images in the word file, you should also get a folder with a bunch of JPG and PNG image files in it. PNG files are HUGE while JPGs are TINY. We want to lose the PNG and keep the JPG and this will save your big download fees. Look at each image file, you should see the same image, once as a JPG and again as a PNG. If you do, this is good, it means you can reduce the file/download size by roughly the size of all the PNGs. Take note of what the numbers are with the PNGs and JPGs. PNGs are usually (but not always) odds and JPGs are usually evens.

Step 2> RIGHT CLICK on Name.HTM and OPEN WITH NotePad or WordPad but NOT WORD.

Step 3> use the Find function and search for image00
It should find something like this:
<v:imagedata src="./Personal%20space%20w%20cover_files/image001.png" o:title=""/>

Now, you have to do some manual editing, but it's easier than you think.
<v:imagedata src="./Personal%20space%20w%20cover_files/image001.png" o:title=""/>

Select everything from the left of the I in image to the quote, in this case ./Personal%20space%20w%20cover_files/ This part needs to be deleted. In this example, the Folder created was named Personal space cover_files. This tells the browser to look for images in that folder. We're changing that. % generally is a stand in for a blank space. You need to keep the " but lose everything up to the I in image.

It should now look something like this. (Yours will be a little different)
<v:imagedata src="image001.png" o:title=""/>

But you're still not done. We want JPGs because they're smaller. IF the image you've found ends in JPG, then you're done and you can move on and find the next image00 but this one needs a little more editing. Since there is no image001.jpg just changing the jpg isn't going to do. You also have to change the image number. Usually you can just at one to the image number and change it to a JPG, but check before you do.

In my case, it gets changed to this:

<v:imagedata src="image002.jpg" o:title=""/>

Now, go through the rest of the file until you reach the end. Remember, even if you screw this up, it's no big deal, you haven't changed the original DOC it came from, so worry not.

When you get to the end, simply save it and close NotePad or WordPad (whichever you used).

Now make a new folder (something like TEST) and copy the HTM file and all the JPGs (and only the JPGs) into it. Go into it and open the HTM with your browser of choice (NOT WORD!). Scroll through it and see if everything looks right. Pay special attention to the picture files. If something went wrong, you can generally tell because it'll have an empty picture frame where a picture should be. Generally this is caused by forgetting to change the image00 number, or changing a PNG to a JPG, or leaving a period after the first quote.

If it looks good and seems to work fine, great.

Check the sizes of the JPGs. If any of them are over 1 meg in size, consider opening them in an image editor and resaving them in at a lower resolution (changing dimensions sometimes causes problems, so don't resize them unless it can't be helped) check it again and if it looks good on your 16" computer screen, it'll look fine on a 7" Kindle. Remember, you're editing the JPGs in the TEST folder, you still have the originals to fall back on if you screw something up.

Last step> Select everything in your TEST folder (HTM and all of the JPG, that should be all there is in this folder) then RIGHT CLICK, Select SEND TO, and COMPRESSED FOLDER, then answer yes if something gets asked. After a few moments you should see a new file in that folder, ending in .ZIP. This is the file you upload to KDP instead of the normal DOC file.

Last word.

Things happen. You should ALWAYS look at every page in the Kindle Viewer, AND download the HTML file they offer (usually as a ZIP, so unzip it on your computer after downloading), open it in WORD, and use compare to compare it to the original DOC. I have caught GLITCHES before, so ALWAYS do something like this to check your book before going LIVE.

Good luck!

PS, cover image MB size plays big here too

Wednesday, October 16, 2013

Bobblehead and straw tidal generators

Been thinking about tidal power lately. It keeps coming up in my random readings, so I'm guessing the Gods are telling me to revisit it.

In "Wandering Island Factory" I briefly talk about tidal power, so I guess I should be more specific now.

There is no shortage of designs, so I'll just focus on the two I thought were the most viable and the least expensive to implement.

I'll call the first one the straw design.
If you look at a cup of straws and imagine a wave of water in the cup, you'll realize that the air inside each straw is forced up and down as the wave goes through, no matter how small the wave is. Much like with windmills, most wave generators SUCK at harnessing small waves and breezes. But the VAST Majority of all waves are tiny.
This straw approach solves that.
A simple one-way flap valves on the tops of the straws tie the tiny puffs of thousands of straws together into enough of a constant breeze to do something with. Remember, each time the wave recedes it draws a vacuum, each time it advances it increases the pressure.

Now, lets talk about scale, because obviously straws are too tiny to be useful on an ocean. The bundles of 'straws' should be about the size of the typical wave (1-4 feet in diameter) and the height of the straws should also match the typical waves at high and low tides. They can be made to look like massive piers or even those temporary boat bridges or other useful structures or platforms.

Downsides: 'things' will get into them and start attaching to the insides of the straws. This shouldn't impede function for a long time, but it will eventually and cleaning out the straws promises to be a nightmare. Two flap valves per straw could also cause problems with troubleshooting (though flap valves are fairly foolproof).
Big storms and high waves could flood it with water, and that could pose a problem eventually too. Placing a flexible membrane between the waves and the top of the straw to make it a 'closed system' could solve a lot of this, but starts adding expense.

=============

BobbleHead:

Think of a thousand bobble heads turned upside down, their feet glued to a board and you have an idea where this is going.

Basically it's a 55gallon barrel with a piston attaching it like a bobblehead to a superstructure. That main piston acts as a pump every time it bobs up and down. Four other pistons, like spokes on a wheel, act like pumps as the bobble head bobs in the water with the sides of the waves. A simple plastic cover keeps the barrel from filling with water when it rains or storms. The hydraulics from the pumps obviously is where we tap the power.

These are the heavily engineered versions of the straw design and the most similar to the tidal generator used in The Wandering Island Factory. It, by the way, simply used an array of floating blocks connected to each other by a piston/pump on each corner.

I'm partial to the straw design because of its simplicity.