- posting an html export doesn't work (the post shows all your html tags without interpreting them)
- a simple copy / paste makes all your italics, bold, etc. settings disappear in the post
I tried to find a way to convert a Word / OpenOffice / RTF document into something compatible with the language used on the board (BBcode), but I didn't find anything useful (maybe it exists, but I didn't find it).
So, I modified a Word macro created by Alexis Dupont-Roc and released under under GPL licence for another CMS (SPIP), to fit my basic needs of BBcode. As I thought it could be useful to others here, you'll find the VBA code below.
It is not a full conversion tool: it will only convert
- italics,
- text in bold,
- first level titles in centered, size = +5 text,
- second level titles in centered, size = +3 text.
' text in bold Sub bbcodeBold() Selection.Find.ClearFormatting Selection.Find.Font.Bold = True Selection.Find.Replacement.ClearFormatting With Selection.Find .Text = "" .Replacement.Text = "[b]^&[/b]" .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 ' text in bold and italics Sub bbcodeBoldItalics() Selection.Find.ClearFormatting Selection.Find.Font.Italic = True Selection.Find.Font.Bold = True Selection.Find.Replacement.ClearFormatting With Selection.Find .Text = "" .Replacement.Text = "[b][i]^&[/i][/b]" .Replacement.Font.Italic = False .Replacement.Font.Bold = False .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 ' text in italics Sub bbcodeItalics() Selection.Find.ClearFormatting Selection.Find.Font.Italic = True Selection.Find.Replacement.ClearFormatting With Selection.Find .Text = "" .Replacement.Text = "[i]^&[/i]" .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 ' Title1 style => text size = +5 Sub bbcodeTitle1() Dim i As Integer Dim aRange As Range For i = 1 To ActiveDocument.Paragraphs.Count If ActiveDocument.Paragraphs(i).style = ActiveDocument.Styles(wdStyleHeading1) Then ActiveDocument.Paragraphs(i).style = wdStyleNormal Set aRange = ActiveDocument.Range(Start:=ActiveDocument.Paragraphs(i).Range.Start, End:=ActiveDocument.Paragraphs(i).Range.End - 1) aRange.InsertBefore ("[center][size=" + Chr(34) + "5" + Chr(34) + "]") aRange.InsertAfter ("[/size][/center]") End If Next i End Sub ' Title2 style => text size = +3 Sub bbcodeTitle2() Dim i As Integer Dim aRange As Range For i = 1 To ActiveDocument.Paragraphs.Count If ActiveDocument.Paragraphs(i).style = ActiveDocument.Styles(wdStyleHeading2) Then ActiveDocument.Paragraphs(i).style = wdStyleNormal Set aRange = ActiveDocument.Range(Start:=ActiveDocument.Paragraphs(i).Range.Start, End:=ActiveDocument.Paragraphs(i).Range.End - 1) aRange.InsertBefore ("[center][size=" + chr(34) + "3" + chr(34) + "]") aRange.InsertAfter ("[/size][/center]") End If Next i End Sub
How to use these macros?
In MS Word, go to Tools / Macro / Visual Basic Editor
Create a new module
Paste the code above into it.
Back to MS Word, go to Tools / Macro / Macros...: it should show you a list of macros in the active document. If everything went well, you'll find a list of those 5 macros:
- bbcodeBold
- bbcodeBoldItalics
- bbcodeItalics
- bbcodeTitle1
- bbcodeTitle2
Copy and paste the text in a post on the forum!
I strongly advise you not to do this on you original file: use a copy of your file, or create a new file and paste into it your text, then apply the macros (they come as is, without any guarantee as usual).
PS: of course, I thought it would be more useful to fanfic writers, but you can use this to post anywhere else on the CBn board (and other boards using BBcode), the BBcode is always the same.