Microsoft Word Macros

WikiWord
WikiWord is a template for Microsoft Word which is useful both for converting an existing document to Wiki syntax (bold, headings, etc.), and for writing new pages in Wiki syntax. It is based on a conversion template for SPIP.

To install this, copy the file "WikipediaX.dot" (X is the version number) into Word's template folder. To convert, simply click the button "Wikipeedia" in the default Wikipedia toolbar.

Important: It is necessary to disable the automatic conversion of apostrophes (') to typographical ones (’) (select the menu Tools, then AutoCorrection, etc.). Alternatively, you can convert the typographical apostrophes back to simple ones yourself.

Aoineko

Features

 * Convert italic to  italic 
 * Convert bold to  bold 
 * Convert italic&bold to  italic&bold 
 * Convert  underline  to  underline 
 * Convert "point lists" to WikiList (*</tt>, **</tt>, ***</tt>, etc.)
 * Convert "numerical lists" to WikiList (#</tt>, ##</tt>, ###</tt>, etc.)
 * Convert "table" to WikiTable ( {| ... |} </tt>)

Version 0.4
File: fr:Media:Wikipedia4.dot 

Version 0.51
File: fr:Media:Wikipedia51.dot (Description and history)

What's new:
 * Converts lists using * and #
 * Converts tables to Wiki syntax
 * Editing aids: bold, italics, images, links, headings (1, 2, 3)
 * New toolbar

Known bugs:
 * Sometimes the font styles (bold, italics, etc.) are placed at a line break. In such a case it is not necessary to create Wiki syntax. (Translator's note: I'm sorry, I don't know what the original author of this sentence meant. &mdash; Timwi 03:57, 28 Jun 2004 (UTC))

Version 0.52
File: fr:Media:Wikipedia52.dot (Description and history)

What's new:
 * New toolbar icons
 * Automatically selects the word around the cursur when nothing is selected when you click a toolbar button

Known bugs:
 * Like 0.51 with the styles at line breaks.

Word macros
See also: Open Office macros (French), Word macros (Esperanto)

Here are some macros to use in Word for editing Wikipedia articles.

WikiLink
Sub WikiLink ' adds double square brackts around the selected text Selection.Copy Selection.Find.ClearFormatting Selection.Find.Replacement.ClearFormatting With Selection.Find .Text = Selection.Text .Replacement.Text = "" & Selection.Text & "" .Forward = False .Wrap = wdFindContinue .Format = False .MatchCase = False .MatchWholeWord = False .MatchWildcards = False .MatchSoundsLike = False .MatchAllWordForms = False End With With Selection If .Find.Forward = True Then .Collapse Direction:=wdCollapseEnd Else .Collapse Direction:=wdCollapseEnd End If        .Find.Execute Replace:=wdReplaceOne If .Find.Forward = True Then .Collapse Direction:=wdCollapseEnd Else .Collapse Direction:=wdCollapseEnd End If        .Collapse Direction:=wdCollapseEnd .MoveRight Unit:=wdWord, Count:=3 '       .Find.Execute End With End Sub

CursorToEnd
Sub CursorToEnd ' Moves the cursor to the end of the selected text. ' To be used, for example, after WikiLien

Selection.MoveRight Unit:=wdWord, Count:=3, Extend:=wdExtend Selection.MoveLeft Unit:=wdCharacter, Count:=2, Extend:=wdExtend Selection.Copy Application.Run MacroName:="Normal.NewMacros.WikiLien" Selection.MoveRight Unit:=wdWord, Count:=3 Selection.MoveLeft Unit:=wdCharacter, Count:=2 End Sub

Capitalise
Sub Capitalise ' makes all selected text capitals

With Selection.Font .Name = "Times New Roman" .Size = 12 .Bold = False .Italic = False .Underline = wdUnderlineNone .UnderlineColor = wdColorAutomatic .StrikeThrough = False .DoubleStrikeThrough = False .Outline = False .Emboss = False .Shadow = False .Hidden = False .SmallCaps = False .AllCaps = True .Color = wdColorAutomatic .Engrave = False .Superscript = False .Subscript = False .Spacing = 0 .Scaling = 100 .Position = 0 .Kerning = 0 .Animation = wdAnimationNone End With End Sub

-

Sub wp_wiki_table Dim wpTable As Table Dim wpRange As Range For Each wpTable In ActiveDocument.Tables Dim i As Integer Dim j As Integer For i = 1 To wpTable.Rows.Count For j = 1 To wpTable.Columns.Count Selection.Find.ClearFormatting If i = 1 Then wpTable.Cell(i, j).Range.InsertBefore "!" Else wpTable.Cell(i, j).Range.InsertBefore "|" End If            If j = 1 Then If i = 1 Then wpTable.Cell(i, j).Range.InsertBefore "{| border=1 cellspacing=0 " & vbCrLf Else wpTable.Cell(i, j).Range.InsertBefore "|- " & vbCrLf End If            End If             If i = 1 Then wpTable.Cell(i, j).Range.InsertAfter " !" Else If j <> wpTable.Columns.Count Then wpTable.Cell(i, j).Range.InsertAfter " |" End If        Next j '        wpTable.Cell(i, wpTable.Columns.Count).Range.InsertAfter vbCrLf & "|" Next i    wpTable.Cell(wpTable.Rows.Count, wpTable.Columns.Count).Range.InsertAfter vbCrLf & "|} " Set wpRange = wpTable.ConvertToText(Separator:="*") wpRange.Style = wdStylePlainText 'teste si une ligne a bien été laissée avant et après le wpTable If wpRange.Start > 1 Then If ActiveDocument.Characters(wpRange.Start - 2) <> Chr(13) Then wpRange.InsertBefore Chr(13) End If    End If '     If ActiveDocument.Characters(wpRange.End + 1) <> Chr(13) Then '        wpRange.InsertAfter Chr(13) '    End If Next wpTable ReplaceAsteriskSeparator End Sub Sub ReplaceAsteriskSeparator Selection.Find.ClearFormatting Selection.Find.Replacement.ClearFormatting 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 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 End Sub

wp_wiki_table Example
Sub wp_table_html Dim wpTable As Table Dim wpRange As Range For Each wpTable In ActiveDocument.Tables Dim i As Integer Dim j As Integer For i = 1 To wpTable.Rows.Count For j = 1 To wpTable.Columns.Count Selection.Find.ClearFormatting wpTable.Cell(i, j).Range.InsertBefore "&lt;td&gt;" If j = 1 Then wpTable.Cell(i, j).Range.InsertBefore "&lt;tr&gt; " If i = 1 Then wpTable.Cell(i, j).Range.InsertBefore "&lt;table&gt; " End If            End If             wpTable.Cell(i, j).Range.InsertAfter " &lt;/td&gt;" Next j        wpTable.Cell(i, wpTable.Columns.Count).Range.InsertAfter "&lt;/tr&gt; " Next i    wpTable.Cell(wpTable.Rows.Count, wpTable.Columns.Count).Range.InsertAfter "&lt;/table&gt; " Set wpRange = wpTable.ConvertToText(Separator:=" ") wpRange.Style = wdStylePlainText 'teste si une ligne a bien été laissée avant et après le wpTable If wpRange.Start &gt; 1 Then If ActiveDocument.Characters(wpRange.Start - 2) &lt;&gt; Chr(13) Then wpRange.InsertBefore Chr(13) End If    End If     If ActiveDocument.Characters(wpRange.End + 1) &lt;&gt; Chr(13) Then wpRange.InsertAfter Chr(13) End If Next wpTable End Sub