# Microsoft Word integration

To launch XML Copy Editor from Microsoft Word, you can use a simple macro. The following macro will open the active document in XML Copy Editor and display the Spelling and Style dialog:

    Sub xmlcopyeditor()
      On Error GoTo ErrorHandler

      Dim cmd As String
      Dim app As String
      Dim switch As String
      Dim doc As String
      Dim ruleset As String
      Dim filter As String
      Dim applicationDir As String

      app = Chr(34) _
        & "C:\Program Files\XML Copy Editor\xmlcopyeditor.exe" _
        & Chr(34)

      If Application.Documents.Count <> 0 Then
        If ActiveDocument.Path <> "" Then
          switch = "-ws"
          doc = Chr(34) _
            & ActiveDocument.Path _
            & Application.PathSeparator _
            & ActiveDocument.Name & Chr(34)
          ruleset = Chr(34) _
            & "Default dictionary and style" _
            & Chr(34)
          filter = Chr(34) _
            & "WordprocessingML" _
            & Chr(34)
        End If
      End If

      cmd = app & " " _
        & switch & " " _
        & doc & " " _
        & ruleset & " " _
        & filter

      Shell cmd, vbNormalFocus
      On Error GoTo 0
      Exit Sub

    ErrorHandler:
      MsgBox "Unable to open XML Copy Editor"
    End Sub