• The TMF is sponsored by Clips4sale - By supporting them, you're supporting us.
  • >>> If you cannot get into your account email me at [email protected] <<<
    Don't forget to include your username

The TMF is sponsored by:

Clips4Sale Banner

Some Useful Macros

Sablesword

TMF Master
Joined
Jun 13, 2001
Messages
785
Points
18
Recently I was asked how I format my stories & how I deal with the fiddly business of arranging proper formatting when I post something here. My answer was that I write using MS Word, and then create a "markup copy" of the finished story. I apply various macros to this copy of the story to mark it up with proper formatting and BB code, and then copy & paste it here.

After creating (and saving!) a "markup copy" of my story, I first apply a macro to replace the tabs used to indent paragraphs with a blank line between paragraphs.

Then, I run a macro to replace all the curly ("smart") quotes with straight quotes. This macro also replaces a couple of other bits of typographical fanciness with the flat-ascii version.

Then, I run a macro to mark all the italic words and phrases with [i][/i] tags.

Then I run a macro to replace all the #'s I use to mark off sections with the tagged version: [center]#[/center]

Finally I save the mark-up copy of the story, and then copy & paste it into a TT post.

And here are the macros. You can copy and paste them into your visual basic editor, invoked from MS Word.


Sub tab2para()
'
' tab2para Macro
' This macro removes the tab mark at the beginning of each
' paragraph and replaces it with an extra paragraph mark.
' This changes the paragraph formatting from indented to
' blank-line-between each paragraph.
'
Selection.Find.ClearFormatting
Selection.Find.Replacement.ClearFormatting
With Selection.Find
.Text = "^p ^t"
.Replacement.Text = "^p^p "
.Forward = True
.Wrap = wdFindContinue
.Format = False
.MatchCase = False
.MatchWholeWord = False
.MatchWildcards = False
.MatchSoundsLike = False
.MatchAllWordForms = False
End With
Selection.Find.Execute Replace:=wdReplaceAll
End Sub

Sub De_curl()
'
' De_curl Macro
' This macro replaces curly quotes with straight quotes,
' en-dashes with hyphens, and ellipses with three periods
'
With Options
.AutoFormatAsYouTypeReplaceQuotes = False
.AutoFormatReplaceQuotes = False
End With
Selection.Find.ClearFormatting
Selection.Find.Replacement.ClearFormatting
With Selection.Find
.Text = """"
.Replacement.Text = """"
.Forward = True
.Wrap = wdFindStop
.Format = False
.MatchCase = False
.MatchWholeWord = False
.MatchWildcards = False
.MatchSoundsLike = False
.MatchAllWordForms = False
End With
Selection.Find.Execute Replace:=wdReplaceAll
With Selection.Find
.Text = "'"
.Replacement.Text = "'"
.Forward = True
.Wrap = wdFindStop
.Format = False
.MatchCase = False
.MatchWholeWord = False
.MatchWildcards = False
.MatchSoundsLike = False
.MatchAllWordForms = False
End With
Selection.Find.Execute Replace:=wdReplaceAll
With Selection.Find
.Text = "–"
.Replacement.Text = "-"
.Forward = True
.Wrap = wdFindStop
.Format = False
.MatchCase = False
.MatchWholeWord = False
.MatchWildcards = False
.MatchSoundsLike = False
.MatchAllWordForms = False
End With
Selection.Find.Execute Replace:=wdReplaceAll
With Selection.Find
.Text = "…"
.Replacement.Text = "..."
.Forward = True
.Wrap = wdFindStop
.Format = False
.MatchCase = False
.MatchWholeWord = False
.MatchWildcards = False
.MatchSoundsLike = False
.MatchAllWordForms = False
End With
Selection.Find.Execute Replace:=wdReplaceAll
'
' This section turns automatic smart quotes back on
' If you normally leave smart quotes off
' Then you need to delete the following
' "With Options...End With"
'
With Options
.AutoFormatAsYouTypeReplaceQuotes = True
.AutoFormatReplaceQuotes = True
End With
End Sub

Sub Italic2tag()
'
' ReplaceItalicsWithTag Macro
'
' Searches through a document and inserts an Tag [I][/I]
' character before and after all text with italic formatting,
' and removes the italic formatting.
' copied from a usenet post by Robert Kerr & modified
' & modified 11/08/2005

Dim boolFoundItalic As Boolean
boolFoundItalic = False

Selection.HomeKey unit:=wdStory
Selection.Find.ClearFormatting
Selection.Find.Font.Italic = True

' Loop through each instance of italics in the document
Do
' Set the find parameters
With Selection.Find
.Text = ""
.Replacement.Text = ""
.Forward = True
.Wrap = wdFindContinue
.Format = True
.Font.Italic = True
.MatchCase = False
.MatchWholeWord = False
.MatchWildcards = False
.MatchSoundsLike = False
.MatchAllWordForms = False
End With

If Selection.Find.Execute Then
boolFoundItalic = True
Else
boolFoundItalic = False
End If

If boolFoundItalic Then
With Selection
.InsertBefore "[I]"
.InsertAfter "[/I]"
.Font.Italic = False
End With
End If

Loop Until boolFoundItalic = False
End Sub

Sub TagSectionMark()
'
' TagSectionMark Macro
' This macro replaces all "#" (which I use as section markers)
' with the tagged version: [center]#[/center]
'
Selection.Find.ClearFormatting
Selection.Find.Replacement.ClearFormatting
With Selection.Find.Replacement.ParagraphFormat
.SpaceBeforeAuto = False
.SpaceAfterAuto = False
.Alignment = wdAlignParagraphLeft
End With
Selection.Find.Replacement.ParagraphFormat.Borders.Shadow = False
With Selection.Find
.Text = "#"
.Replacement.Text = "[center]#[/center]"
.Forward = True
.Wrap = wdFindContinue
.Format = True
.MatchCase = False
.MatchWholeWord = False
.MatchWildcards = False
.MatchSoundsLike = False
.MatchAllWordForms = False
End With
Selection.Find.Execute Replace:=wdReplaceAll
End Sub
 
Thanks, SableSword! This will come in real handy for me! Your input, as always, is much appreciated!
 
SableSword, I created the macros. The de-curl and the Italics ones work great. The first one (tab2para) didn't seem to work. I'm thinking I may have done something wrong. Do you save the file as a Word doc or rtf, run the macro, then resave as a doc or rft? Or do you resave it in a different format (ex. txt)?

Any pointers?
 
How do you indent your paragraphs? I set mine by putting an actual tab character at the beginning of each paragraph, with a "manual" tab stop set in the Normal style. But some people do it by adjusting the ruler to indent the first line of each paragraph.

I think there's a "helpful" word setting that automagically adjusts the ruler if you press the tab key at the beginning of a paragraph. If that's what you use, then the tab2para macro won't work for you - it searches for actual tab characters.

(I always turn the "helpful" word settings OFF OFF OFF when I first install Word.)
 
Well Sablesword, i remember you helping me with my story format..now when i write a story, i do all that manually...create a paragraph as i'm writing..etc...on word pad..then copy and paste...

And always making sure conversations have their own paragraph...it does make for easier writing..i cringe when i look back at some of my earlier works..i should change them, however i'm too lazy lol...also, they are under the name, Melanie..and i've forgotten that password..
 
How do you indent your paragraphs? I set mine by putting an actual tab character at the beginning of each paragraph, with a "manual" tab stop set in the Normal style. But some people do it by adjusting the ruler to indent the first line of each paragraph.

I think there's a "helpful" word setting that automagically adjusts the ruler if you press the tab key at the beginning of a paragraph. If that's what you use, then the tab2para macro won't work for you - it searches for actual tab characters.

(I always turn the "helpful" word settings OFF OFF OFF when I first install Word.)

I had the paragraph formating on to auto-indent the first line of the paragraph. From here on, I'll indent it myself. That must have been the problem
 
What's New

5/9/2024
If you need to report a post, the report button is to its lower left.
Tickle Experiment
Door 44
NEST 2024
Register here
The world's largest online clip store
Live Camgirls!
Live Camgirls
Streaming Videos
Pic of the Week
Pic of the Week
Congratulations to
*** brad1701 ***
The winner of our weekly Trivia, held every Sunday night at 11PM EST in our Chat Room
Back
Top