VBA/Excel/Access/Word/Word/Document Format

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

Making Sure an Item Is Displayed in the Window

 
Sub range()
    Dim rngFirstList As Range
    Set rngFirstList = ActiveDocument.Lists(1).Range
    ActiveDocument.Windows(1).ScrollIntoView Obj:=rngFirstList, Start:=False
    rngFirstList.Select
    Selection.Collapse Direction:=wdCollapseEnd
    Selection.MoveLeft Unit:=wdCharacter, Count:=1, Extend:=wdMove
End Sub



Open MS-word and format the text

 
Sub Open_MSWord()
    On Error GoTo errorHandler
    Dim wdApp As Word.Application
    Dim myDoc As Word.Document
    Dim mywdRange As Word.Range
    Set wdApp = New Word.Application
   
    With wdApp
        .Visible = True
        .WindowState = wdWindowStateMaximize
    End With
   
    Set myDoc = wdApp.Documents.Add
   
    Set mywdRange = myDoc.Words(1)
   
    With mywdRange
        .Text = Range("F6") & " This text is being used to test subroutine." & _
            "  More meaningful text to follow."
        .Font.Name = "Comic Sans MS"
        .Font.Size = 12
        .Font.ColorIndex = wdGreen
        .Bold = True
    End With
   
    errorHandler:
   
    Set wdApp = Nothing
    Set myDoc = Nothing
    Set mywdRange = Nothing
End Sub