VBA/Excel/Access/Word/Word/Word Format — различия между версиями

Материал из VB Эксперт
Перейти к: навигация, поиск
м (1 версия)
 
(нет различий)

Текущая версия на 12:48, 26 мая 2010

changing the formatting of entire paragraphs is to change the style

 
Sub ChangeStyle()
    Dim wdApp As Word.Application
    Dim wdRng As Word.Range
    Dim count As Integer
    
    Set wdApp = GetObject(, "Word.Application")
    
    With wdApp.ActiveDocument
        For count = 1 To .Paragraphs.count
            Set wdRng = .Paragraphs(count).Range
            With wdRng
                If .Style = "NO" Then
                    .Style = "HA"
                End If
            End With
        Next count
    End With
    
    Set wdApp = Nothing
    Set wdRng = Nothing
End Sub



Format a Range

 
Sub ChangeFormat()
    Dim wdApp As Word.Application
    Dim wdRng As Word.Range
    Dim count As Integer
    
    Set wdApp = GetObject(, "Word.Application")
    
    With wdApp.ActiveDocument
        For count = 1 To .Paragraphs.count
            Set wdRng = .Paragraphs(count).Range
            With wdRng
                .Words(1).Font.Bold = True
            End With
        Next count
    End With
    
    Set wdApp = Nothing
    Set wdRng = Nothing
End Sub