объекты Word

  • View
    6

  • Download
    0

Embed Size (px)

Transcript

  • :

    ..

    927.psd

    928.psd

  • Application Application Microsoft Word. Word "" . , Word . Dim oWord As New Word.Application oWord.Visible = True oWord.Documents.Add

  • VBA Word Application . , , VBA , Application. : Application.Selection.TypeText " " Selection.TypeText " "

  • , Application ActiveDocument Word. Application, : ActiveDocument.Save Caption "Microsoft Word" , " ".

  • Dialogs Dialogs, Word. Dim oDlg As DialogSet oDlg = Application.Dialogs(wdDialogFileOpen)If oDlg.Display = -1 ThenMsgBox : " & _ Application.Options.DefaultFilePath _ (wdCurrentFolderPath) & "\" & oDlg.NameEnd If

  • :Dim oDlg As DialogSet oDlg = Application.Dialogs(wdDialogFileOpen)oDlg.Show .

  • Documents . . NewDocument Word. NewDocument. Application.NewDocument.Add(). Option Option. ( | ). Path Word .

  • KeyBoard() Word, . : Application.Keyboard 1049 : Application.Keyboard 1033 ListCommands() Word, , .

  • OnTime() Word , - . Word . . Quit() , Word .

  • Documents Document Application Word Documents Document, . Word .

  • : Word. . - (, , ). Word Application. , , , . . Documents Document. Selection, Range Bookmark.

  • Documents Add() .

  • :Dim oDoc As Word.Document Set oDoc = Documents.Add[, _] , , . _ , ( True) ( False).

    Dim oDoc As Word.Document Set oDoc = Application.Documents.Add("C:\dog_blank.dot")

  • Open() : Dim oDoc1 As Word.Document Set oDoc1 = Documents.Open("c:\doc1.doc") , , . Save() Close()

  • Item() . For...Next - If...Then. Name: Dim oDoc1 As Word.Document For i = 1 To Documents.Count Set oDoc1 = Documents.Item(i) MsgBox Documents.Item(i).Name If oDoc1.Name = "doc1.doc" Then Exit For End If Set oDoc1 = Nothing Next oDoc1 doc1.doc, . , . , .

  • Item() . , Documents: Dim oDoc1 As Word.DocumentFor i = 1 To Documents.Count Set oDoc1 = Documents.Item(i) Debug.Print Documents.Item(i).NameNext

  • Document, , Application Word, Documents ( , ) , , , Document. Document , .

  • Document: Documents. , , Documents.Item(1); ThisDocument , , : MsgBox ThisDocument.Name ActiveDocument Application. : MsgBox Application.ActiveDocument.Name MsgBox ActiveDocument.Name

  • Document Characters Range, . Document, Selection Range. , , (, ); FullName ( ) Paragraphs

  • Document Activate() (, ). PrintOut() , . Range() Range, Select() . , Selection Range

  • Selection, Range Bookmark , , , , . Selection, Range Bookmark. .

  • Selection , - Word, , . Selection ( , , ).

  • Selection . Word . : Application.Selection.Text = " " : Selection.Text = " " , Selection, .

  • Word: . , . Select(), (Document, Range, Bookmark, Table , PageNumber, Field . .). , , . .

  • Selection, .

    Find .

    , . . .

  • Selection Bookmarks Bookmarks, .. , . Start End , ( , , ). 0. , , .

  • Font Font, .

    , Arial 10 pt, : Selection.Font.Name = "Arial" Selection.Font.Size = 10

  • Text Selection. ( , )., 100 "!", : For i = 0 To 100 Selection.Text = "!" Selection.EndOf Next EndOf() . , 100 , .

  • Selection Collapse() . : . , . Copy(), CopyAsPicture(), Cut(), Paste() Delete() , , , .

  • Next() , , , , , . . Previous(). SelectColumn(), SelectRow(), SelectCell() Word.

  • Range Range , . Range , . Range Selection Range, . ( ). Range , Selection .

  • Range Range() Document. :.Range[Start, End] Start End , . , , ., , 10 , : Dim rngDoc As Range Set rngDoc = ActiveDocument.Range(Start:=0, End:=10) :ActiveDocument.Range(Start:= 10, End:=20) , 11- 20- . , , . , 0 , 10 10- 11- .

  • (Characters, Words, Sentences . .), Range. Range.

    (, , . .), , . Range, ( , ..).

  • Range Range Selection. Text , , , . IsEqual() Range ( Selection Range). , , True. Select() Selection Range (. . ).

  • SetRange() . , Range, ( ), : Dim MyRange As Range Set MyRange = ActiveDocument.Range(Start:=0, End:=0) MyRange.SetRange Start:=MyRange.Start, _ End:=Selection.End MyRange.Select '

  • Bookmark Bookmark . , (, ). Selection Range , , . , , , .

  • Bookmark ( Bookmarks, ) Selection ( Select()) Range ( Range), , : ThisDocument.Bookmarks("Bookmark1").Select MsgBox Selection.Text

  • Bookmark Empty True, , ; Name . , Bookmarks () , . Range Range .

  • Bookmark Copy() .

    Delete() .

    Select() , .

  • Table, Column, Row Cell - (, , . .), , , . .

  • , Tables ( Document, Selection Range) Table ( ): Set Range1 = ThisDocument.Range(Start:=0, End:=0) Dim Table1 As Table Set Table1 = ThisDocument.Tables.Add(Range1, 3, 4)

  • , , AutoFormat(): Table1.AutoFormat wdTableFormatGrid5 - . Word Cell. Columns Rows, Selection Range, : Table1.Cell(1, 1).Range.InsertAfter "10" Table1.Cell(2, 1).Range.InsertAfter "15" Table1.Cell(3, 1).AutoSum 10, 15, . Word , , Excel, Formula() Cell .