forex trading logo



Match styles with attached DOT

User Rating:  / 0

The following code synchronizes the styles in your document with the attached template (.DOT).

Sub MatchStylesWithAttachedDOT()

  Dim doc1 As Word.Document
  Dim doc2 As Word.Document
     Set doc1 = ActiveDocument
  Dim DotStylesListe As String:    DotStylesListe = ""
  Dim astyle As Style
  Documents.Open FileName:=ActiveDocument.AttachedTemplate.Path _
          & Application.PathSeparator & ActiveDocument.AttachedTemplate, ReadOnly:=True
  Set doc2 = ActiveDocument
  For Each astyle In ActiveDocument.Styles
    If astyle.InUse = True Then
       DotStylesListe = DotStylesListe & astyle.NameLocal & "   "
    End If
  doc2.Close SaveChanges:=False

Dim Query
Dim MsgBoxAnzeige
  MsgBoxAnzeige = "Only the following styles from template file '" _
         & ActiveDocument.AttachedTemplate & "' are allowed. " _
         & vbCrLf & "Do you want to accept them?" & vbCrLf & vbCrLf & DotStylesListe
  Query = MsgBox(MsgBoxAnzeige, vbYesNo + vbDefaultButton2, "Getting rid of unauthorized styles")
  If Query <> 6 Then Exit Sub
  On Error Resume Next
  For Each astyle In ActiveDocument.Styles
    If astyle.InUse = True Then
        If InStr(DotStylesListe, astyle.NameLocal) = 0 Then
          Application.OrganizerCopy _
            Source:=ActiveDocument.AttachedTemplate.FullName, _
            Destination:=ActiveDocument.FullName, _
            Name:=astyle, _
        End If
    End If
  Next astyle
  On Error GoTo 0
   Call ResetHeadlines
End Sub
Sub ResetHeadlines()

     Dim para As Paragraph
     For Each para In ActiveDocument.Paragraphs

     If Left(para.Style, 11) = "Headline" _
     Or LCase(Left(para.Style, 1)) = "a" Then

     End If
   Next para
End Sub


Powered by Joomla!. Design by: joomla templates download  Valid XHTML and CSS.