1c1,2 < Attribute VB_Name = "Module1" --- > Attribute VB_Name = "Word2TWiki" > 5c6 < 'For references: http://www.twiki.org/bin/view/Plugins/MsWordToTWikiMLAddOn --- > 'For references: http://www.twiki.org/cgi-bin/view/Plugins/MsWordToTWikiMLAddOn 9,17c10 < CleanFormattingParagraphEndingsBold < CleanFormattingParagraphEndingsItalic < < ConvertH1 < ConvertH2 < ConvertH3 < ConvertH4 < ConvertH5 < ConvertH6 --- > CleanFormattingParagraphEndings 19,20c12,26 < ConvertItalic < ConvertBold --- > ConvertHeading "---+", wdStyleHeading1 > ConvertHeading "---++", wdStyleHeading2 > ConvertHeading "---+++", wdStyleHeading3 > ConvertHeading "---++++", wdStyleHeading4 > ConvertHeading "---+++++", wdStyleHeading5 > ConvertHeading "---++++++", wdStyleHeading6 > > ConvertStyle "__", bold:=True, italic:=True > ConvertStyle "*", twikiCode2:="*", bold:=True, underline:=wdUnderlineSingle > ConvertStyle "==", bold:=True, fontName:="Courier New" > > ConvertStyle "*", bold:=True > ConvertStyle "_", italic:=True > ConvertStyle "", twikiCode2:="", underline:=wdUnderlineSingle > ConvertStyle "=", fontName:="Courier New" 156,157c162 < Private Sub CleanFormattingParagraphEndingsBold() < Selection.Find.ClearFormatting --- > Private Sub CleanFormattingParagraphEndings() 158a164,165 > .ClearFormatting > 'Target 160c167 < .Font.Bold = True --- > 'Replacement 163,180d169 < .Replacement.Text = "^p" < .Wrap = wdFindContinue < .Format = True < .MatchCase = False < .MatchWholeWord = True < .MatchWildcards = False < .MatchSoundsLike = False < .MatchAllWordForms = False < End With < Selection.Find.Execute Replace:=wdReplaceAll < End Sub < < Private Sub CleanFormattingParagraphEndingsItalic() < Selection.Find.ClearFormatting < With Selection.Find < .Text = "^p" < .Font.Italic = True < .Replacement.ClearFormatting 181a171,172 > .Replacement.Font.underline = wdUnderlineNone > .Replacement.Font.Name = "Arial" 182a174 > 'Options 194,405c186 < Private Sub ConvertH1() < Dim normalStyle As Style < Set normalStyle = ActiveDocument.Styles(wdStyleNormal) < < ActiveDocument.Select < < With Selection.Find < < .ClearFormatting < .Style = ActiveDocument.Styles(wdStyleHeading1) < .Text = "" < < .Format = True < .MatchCase = False < .MatchWholeWord = False < .MatchWildcards = False < .MatchSoundsLike = False < .MatchAllWordForms = False < < .Forward = True < .Wrap = wdFindContinue < < Do While .Execute < With Selection < If InStr(1, .Text, vbCr) Then < ' Just process the chunk before any newline characters < ' We'll pick-up the rest with the next search < .Collapse < .MoveEndUntil vbCr < End If < < ' Don't bother to markup newline characters (prevents a loop, as well) < If Not .Text = vbCr Then < .InsertBefore "---+ " < End If < < .Style = normalStyle < End With < Loop < End With < End Sub < < < Private Sub ConvertH2() < Dim normalStyle As Style < Set normalStyle = ActiveDocument.Styles(wdStyleNormal) < < ActiveDocument.Select < < With Selection.Find < < .ClearFormatting < .Style = ActiveDocument.Styles(wdStyleHeading2) < .Text = "" < < .Format = True < .MatchCase = False < .MatchWholeWord = False < .MatchWildcards = False < .MatchSoundsLike = False < .MatchAllWordForms = False < < .Forward = True < .Wrap = wdFindContinue < < Do While .Execute < With Selection < If InStr(1, .Text, vbCr) Then < ' Just process the chunk before any newline characters < ' We'll pick-up the rest with the next search < .Collapse < .MoveEndUntil vbCr < End If < < ' Don't bother to markup newline characters (prevents a loop, as well) < If Not .Text = vbCr Then < .InsertBefore "---++ " < End If < < .Style = normalStyle < End With < Loop < End With < End Sub < < Private Sub ConvertH3() < Dim normalStyle As Style < Set normalStyle = ActiveDocument.Styles(wdStyleNormal) < < ActiveDocument.Select < < With Selection.Find < < .ClearFormatting < .Style = ActiveDocument.Styles(wdStyleHeading3) < .Text = "" < < .Format = True < .MatchCase = False < .MatchWholeWord = False < .MatchWildcards = False < .MatchSoundsLike = False < .MatchAllWordForms = False < < .Forward = True < .Wrap = wdFindContinue < < Do While .Execute < With Selection < If InStr(1, .Text, vbCr) Then < ' Just process the chunk before any newline characters < ' We'll pick-up the rest with the next search < .Collapse < .MoveEndUntil vbCr < End If < < ' Don't bother to markup newline characters (prevents a loop, as well) < If Not .Text = vbCr Then < .InsertBefore "---+++ " < End If < < .Style = normalStyle < End With < Loop < End With < End Sub < < Private Sub ConvertH4() < Dim normalStyle As Style < Set normalStyle = ActiveDocument.Styles(wdStyleNormal) < < ActiveDocument.Select < < With Selection.Find < < .ClearFormatting < .Style = ActiveDocument.Styles(wdStyleHeading4) < .Text = "" < < .Format = True < .MatchCase = False < .MatchWholeWord = False < .MatchWildcards = False < .MatchSoundsLike = False < .MatchAllWordForms = False < < .Forward = True < .Wrap = wdFindContinue < < Do While .Execute < With Selection < If InStr(1, .Text, vbCr) Then < ' Just process the chunk before any newline characters < ' We'll pick-up the rest with the next search < .Collapse < .MoveEndUntil vbCr < End If < < ' Don't bother to markup newline characters (prevents a loop, as well) < If Not .Text = vbCr Then < .InsertBefore "---++++ " < End If < < .Style = normalStyle < End With < Loop < End With < End Sub < < Private Sub ConvertH5() < Dim normalStyle As Style < Set normalStyle = ActiveDocument.Styles(wdStyleNormal) < < ActiveDocument.Select < < With Selection.Find < < .ClearFormatting < .Style = ActiveDocument.Styles(wdStyleHeading5) < .Text = "" < < .Format = True < .MatchCase = False < .MatchWholeWord = False < .MatchWildcards = False < .MatchSoundsLike = False < .MatchAllWordForms = False < < .Forward = True < .Wrap = wdFindContinue < < Do While .Execute < With Selection < If InStr(1, .Text, vbCr) Then < ' Just process the chunk before any newline characters < ' We'll pick-up the rest with the next search < .Collapse < .MoveEndUntil vbCr < End If < < ' Don't bother to markup newline characters (prevents a loop, as well) < If Not .Text = vbCr Then < .InsertBefore "---+++++ " < End If < < .Style = normalStyle < End With < Loop < End With < End Sub < < Private Sub ConvertH6() --- > Private Sub ConvertHeading(twikiCode As String, heading As WdBuiltinStyle) 414c195 < .Style = ActiveDocument.Styles(wdStyleHeading6) --- > .style = ActiveDocument.Styles(heading) 438c219 < .InsertBefore "---++++++ " --- > .InsertBefore twikiCode + " " 447,448c228,229 < Private Sub ConvertBold() < 'This function converts Bold text in Word to TWiki markup --- > Private Sub ConvertStyle(twikiCode1 As String, Optional twikiCode2 As String, Optional bold As Boolean = False, Optional italic As Boolean = False, Optional underline As WdUnderline = wdUndefined, Optional fontName As String = "") > 'This function converts styled text in Word to TWiki markup 450,452c231,233 < 'This function also solves the problem that if a word is in bold or < 'italics, and the trailing space is also in bold/italics, then < 'a space will be placed before the trailing * or _ causing the --- > 'This function also solves the problem that if a word is in a style, > 'and the trailing space is also in that style, then > 'a space will be placed before the trailing wikiCode causing the 464,466c245,254 < < Selection.Find.ClearFormatting < --- > > With Selection.Find > .ClearFormatting > .Replacement.ClearFormatting > .MatchSoundsLike = False > .MatchAllWordForms = False > .Forward = True > .Wrap = wdFindContinue > End With > 468,471c256,262 < ' * find: (empty) Formatted:Bold < ' * repl: ^& Formatted:NotBold < With Selection.Find < .Font.Bold = True --- > ' * find: (empty) Formatted:Style > ' * repl: ^& Formatted:NotStyle > With Selection.Find > .Font.bold = bold > .Font.italic = italic > .Font.underline = underline > .Font.Name = fontName 473c264 < .Replacement.Text = "^&" --- > .Replacement.Text = "^&" 475,476c266,267 < .Forward = True < .Wrap = wdFindContinue --- > .Replacement.Font.italic = False > .Replacement.Font.underline = wdUnderlineNone 481,482d271 < .MatchSoundsLike = False < .MatchAllWordForms = False 484a274 > 486c276 < ' * find: --- > ' * find: 489c279 < .Text = " " --- > .Text = " " 491,493d280 < .Replacement.Font.Bold = False < .Forward = True < .Wrap = wdFindContinue 498,499d284 < .MatchSoundsLike = False < .MatchAllWordForms = False 501a287 > 503,504c289,290 < ' * find: \( @)< (with wildcards) < ' * repl: --- > ' * find: \( @)< (with wildcards) > ' * repl: 506,509c292,293 < .Text = "\( @)<" < .Replacement.Text = "" < .Forward = True < .Wrap = wdFindContinue --- > .Text = "\( @)<" > .Replacement.Text = "" 513,514d296 < .MatchAllWordForms = False < .MatchSoundsLike = False 519,520c301,302 < ' * find: (>)( @)(\) (with wildcards) < ' * repl: --- > ' * find: (>)( @)(\) (with wildcards) > ' * repl: 522,525c304,305 < .Text = "(>)( @)(\)" < .Replacement.Text = "" < .Forward = True < .Wrap = wdFindContinue --- > .Text = "(>)( @)(\)" > .Replacement.Text = "" 529,530d308 < .MatchAllWordForms = False < .MatchSoundsLike = False 535,536c313,314 < ' * find: (>)\ (with wildcards) < ' * repl: \1 --- > ' * find: (>)\ (with wildcards) > ' * repl: \1 538,541c316,317 < .Text = "(>)\" < .Replacement.Text = "\1 " < .Forward = True < .Wrap = wdFindContinue --- > .Text = "(>)\" > .Replacement.Text = "\1 " 545,546d320 < .MatchAllWordForms = False < .MatchSoundsLike = False 551,552c325,326 < ' * find: \(<) (with wildcards) < ' * repl: \1 --- > ' * find: \(<) (with wildcards) > ' * repl: \1 554,557c328,329 < .Text = "\(<)" < .Replacement.Text = " \1" < .Forward = True < .Wrap = wdFindContinue --- > .Text = "\(<)" > .Replacement.Text = " \1" 561,562d332 < .MatchAllWordForms = False < .MatchSoundsLike = False 567,568c337,338 < ' * find: \(*)\ (with wildcards) < ' * repl: *\1* (Bold) --- > ' * find: \(*)\ (with wildcards) > ' * repl: twikiCode\1twikiCode 570,574c340,341 < .Text = "\(*)\" < .Replacement.Text = "*\1*" < .Replacement.Font.Bold = False < .Forward = True < .Wrap = wdFindContinue --- > .Text = "\(*)\" > .Replacement.Text = twikiCode1 + "\1" + IIf(twikiCode2 = "", twikiCode1, twikiCode2) 578,579d344 < .MatchAllWordForms = False < .MatchSoundsLike = False 586,698d350 < Private Sub ConvertItalic() < 'Convert Italic text in Word to TWiki markup < ' < 'This function also solves the problem that if a word is in bold or < 'italics, and the trailing space is also in bold/italics, then < 'a space will be placed before the trailing * or _ causing the < 'effect to be ignored when first posted to TWiki. < ' < 'The function works in the same manner as ConvertItalic < < Selection.Find.ClearFormatting < Selection.Find.Replacement.ClearFormatting < With Selection.Find < .Font.Italic = True < .Text = "" < .Replacement.Text = "^&" < .Forward = True < .Wrap = wdFindContinue < .Format = True < .MatchCase = False < .MatchWholeWord = False < .MatchWildcards = False < .MatchSoundsLike = False < .MatchAllWordForms = False < End With < Selection.Find.Execute Replace:=wdReplaceAll < Selection.Find.ClearFormatting < Selection.Find.Replacement.Font.Italic = False < With Selection.Find < .Text = " " < .Replacement.Text = "" < .Forward = True < .Wrap = wdFindContinue < .Format = False < .MatchCase = False < .MatchWholeWord = False < .MatchWildcards = False < .MatchSoundsLike = False < .MatchAllWordForms = False < End With < Selection.Find.Execute Replace:=wdReplaceAll < Selection.Find.ClearFormatting < Selection.Find.Replacement.ClearFormatting < With Selection.Find < .Text = "\( @)<" < .Replacement.Text = "" < .Forward = True < .Wrap = wdFindContinue < .Format = False < .MatchCase = False < .MatchWholeWord = False < .MatchAllWordForms = False < .MatchSoundsLike = False < .MatchWildcards = True < End With < Selection.Find.Execute Replace:=wdReplaceAll < With Selection.Find < .Text = "(>)( @)(\)" < .Replacement.Text = "" < .Forward = True < .Wrap = wdFindContinue < .Format = False < .MatchCase = False < .MatchWholeWord = False < .MatchAllWordForms = False < .MatchSoundsLike = False < .MatchWildcards = True < End With < Selection.Find.Execute Replace:=wdReplaceAll < With Selection.Find < .Text = "(>)\" < .Replacement.Text = "\1 " < .Forward = True < .Wrap = wdFindContinue < .Format = False < .MatchCase = False < .MatchWholeWord = False < .MatchAllWordForms = False < .MatchSoundsLike = False < .MatchWildcards = True < End With < Selection.Find.Execute Replace:=wdReplaceAll < With Selection.Find < .Text = "\(<)" < .Replacement.Text = " \1" < .Forward = True < .Wrap = wdFindContinue < .Format = False < .MatchCase = False < .MatchWholeWord = False < .MatchAllWordForms = False < .MatchSoundsLike = False < .MatchWildcards = True < End With < Selection.Find.Execute Replace:=wdReplaceAll < Selection.Find.ClearFormatting < Selection.Find.Replacement.ClearFormatting < With Selection.Find < .Text = "\(*)\" < .Replacement.Text = "_\1_" < .Replacement.Font.Italic = False < .Forward = True < .Wrap = wdFindContinue < .Format = True < .MatchCase = False < .MatchWholeWord = False < .MatchAllWordForms = False < .MatchSoundsLike = False < .MatchWildcards = True < End With < Selection.Find.Execute Replace:=wdReplaceAll < End Sub < 778a431,432 > >