???? ID: 212682 - ????? ???????: 18 ??????? 2011 - ??????: 3.0

Word 2000 ?? ???? ????????? ??? ??? ?? ???????? ???? ?? ??? VBA ?????? ??????

?????? ??????This article applies to a different operating system than the one you are using. Article content that may not be relevant to you is disabled.
???? Microsoft Word 98 Macintosh ??????? ?? ??????? ?? ??? ?? ????, ?????183866  (http://support.microsoft.com/kb/183866/ ) .
???? Microsoft Word 97 ?? ??????? ?? ??? ?? ????, ?????161407  (http://support.microsoft.com/kb/161407/ ) .

?? ????? ??

??? ?? ??????? ???? | ??? ?? ??????? ????

??????

?? ???? ????????? ?????? ???????? ?? ????? ???? ???? ?? ??? ?? Visual Basic ?????? ???? ???????? ??????????? ?? ???? ???????? ??? ???????? ???? ?? ??? ???????? ???

???? ???????

Microsoft ???????????? ?????? ???? ???????? ?? ??? ??? ???? ??, ???? ??? ??? ?? ?????? ?? ?????????? ??? ??? ?????? ???? ?? ????.. ?????? ???????? ?????? ?? ???? ????? ???????? ?? ??? ???????? ????? ??? ?? ???? ?? ????? ???? ???.. ?? ??? ????? ?? ?? ?? ????? ?? ?? ??? ???????????? ???? ?? ?? ??????? ?? ?????? ??? ????? ????? ???????????? ?? ????? ?? ???? ???? ?? ??? ???? ?? ??? ??.. Microsoft ?????? ???????? ?? ????? ????????? ?? ???????????? ?? ?????? ??? ?????? ?? ???? ???, ??, ?? ?? ???????? ?? ???? ??????? ?????????? ?? ?????? ???? ?? ??? ???????? ??????????????? ?? ?????? ?? ???????????? ????? ?? ??? ??????? ???? ??????..

??? ???????? ?? TypeText ???? ?? ????? ????

????????? ??? ???????? ???? ??? ???ReplaceSelection??? ??True, ??? ?????? ????????? ??? ???? ??? ??? ???ReplaceSelection??? ?????, ????????? ??? ?? ??? ???? ?? ???? ???? ?? ???

ReplaceSelection ???, Visual Basic ?????? ???, ?? ???? ??? ???? ??????? ?? ??? ????? ????Microsoft Visual Basic ??????????? ???????????, ??????ReplaceSelection ???Office ????? ?? ????? ????????, ?? ???? ?????????? ?? ??????
Sub TypeTextMethod()
  Dim MyText As String
  MyText = "<Replace this with your text>"
  Selection.TypeText (MyText)
End Sub
				

?????? ???????? ?? ????? ????

????? ?????? ???? ???????? ?? ???? ??????? ?? ??????? ????? ?? ??????? ?????? ?? ???? "Replaced" ???? ?? ????? ???

Sub RangeProperty()
  ' Range Example:
  ActiveDocument.Range.Text = "Replaced"
End Sub
				

?????? ?? ??? ???????? InsertAfter/InsertBefore ???? ?? ??? ????? ????

InsertAfter???? ??????:

????????? ??? ?? ???? ?????? ?? ??? ?? ??? ??? ???????? ???? ???
Sub InsertAfterMethod()
  Dim MyText As String
  Dim MyRange As Object
  Set MyRange = ActiveDocument.Range
  MyText = "<Replace this with your text>"
  ' Selection Example:
  Selection.InsertAfter (MyText)
  ' Range Example:
  ' (Inserts text at the current position of the insertion point.)
  MyRange.Collapse
  MyRange.InsertAfter (MyText)
End Sub
				
InsertBefore???? ??????:

????????? ??? ?? ???? ?????? ?? ??? ?? ?????? ??? ???????? ???? ??? ?? ??????? ???? ?? ???? ?? ???? ?? ?? ??, ?? ??? ??? ?? ?????? ?? ??? ??? ?? ????? ???? ?? ????
Sub InsertBeforeMethod()
   Dim MyText As String
   Dim MyRange As Object
   Set MyRange = ActiveDocument.Range
   MyText = "<Replace this with your text>"
   ' Selection Example:
   Selection.InsertBefore (MyText)
   ' Range Example: Inserts text at the beginning
   ' of the active document.
   MyRange.InsertBefore (MyText)
End Sub
				

?????? ?? ??? ???????? ?? ????? ?? ???????? ??? ??? ??????? ???????? ????

??????? ????? ?? ??????? ?????? ?? ??? ??????? ???????? ???? ???
Sub CommentsCollectionObject()
   Dim MyText As String
   Dim MyRange As Object
   Set MyRange = ActiveDocument.Range
   MyText = "<Replace this with your text>"
  ' Selection Example:
  Selection.Comments.Add Range:=Selection.Range, Text:=MyText
  ' Range Example:
  MyRange.Comments.Add Range:=Selection.Range, Text:=MyText
End Sub
				

?????? ?? ??? ???????? ?? ????? ?? ???????? ??? ??? ????? ???????? ????

??????? ????? ?? ??????? ?????? ?? ??? ????? ???????? ???? ???
Sub FieldsCollectionObject()
   Dim MyText As String
   Dim MyRange As Object
   Set MyRange = Selection.Range
   MyText = "<Replace this with your text>"
   ' Selection Example:
   Selection.Fields.Add Range:=Selection.Range, _
      Type:=wdFieldQuote, Text:=MyText
   ' Range Example:
    Range.Fields.Add Range:=Selection.Range, _
      Type:=wdFieldQuote, Text:=MyText
End Sub
				
?? ?????? ???? ????? ????? ???????? ???? ???? ?????? ???? ???? ????? ?? ??? ???????? ?? ?? ???

Sub InsertFormulaMethod()
   Selection.InsertFormula Formula:="=100,000.0-45,000.0", _
      NumberFormat:="$#,##0.0"
End Sub
				

??? ?? ???? ?????? ??, ?????? ????, ??? replicating

?? ??? ???? ?? ???????????????? ?? ???? ??????? ?? ??? ?? ????????? ?????? ?? ??? ?? ??? ???????? ??????? ???????? ?????? ??? ????? ?? ??? ??? ?? ?????? ??? ?? ???????? ????? ??? ?? ?? ?? ??? ???, ?????? ??? ??? ???????? ??? ?? ???? ??? ??? ??? ?? ???? ????? ?? ?????? ??? ?? ????? ?? ???, ?? ?????????????? ?????? ??? ?? ????? ???? ?? ???? ?????? ???
Sub FormattedTextProperty()
   ' This example copies the first paragraph in the document, including
   ' its formatting, and inserts the formatted text at the insertion
   ' point.
   Selection.Collapse Direction:=wdCollapseStart
   Selection.FormattedText = ActiveDocument.Paragraphs(1).Range
End Sub
				

??? ?? ????? ??? ?? ??? ??? ??? ????

???::HeaderFooter??? ?? ???????? ?? ?? ??? ???? ????? ??? ?? ??? ??? ??? ????? ??, ?? ??? ?????? ?? ??????
Sub HeaderFooterProperty()
   Dim MyText As String
   MyText = "<Replace this with your text>"
   ActiveWindow.ActivePane.View.SeekView = wdSeekCurrentPageHeader
   Selection.HeaderFooter.Range.Text = "MyText"
   ActiveWindow.ActivePane.View.SeekView = wdSeekMainDocument
End Sub
				
????? ?????? ??? ???????? ????? ??? ?? ?????? ???????? ?? ???? ??? ?? ??? ???????? ??? ??? ?? ??? ????????? ???? ???
Sub HeaderFooterObject()
  Dim MyText As String
  MyHeaderText = "<Replace this with your text>"
  MyFooterText = "<Replace this with your text>"
  With ActiveDocument.Sections(1)
    .Headers(wdHeaderFooterPrimary).Range.Text = MyHeaderText
    .Footers(wdHeaderFooterPrimary).Range.Text = MyFooterText
  End With
End Sub
				

??? ????? ?? ????? ???? ??? ??? ?????? ???????? ???? ?? ??? ?????? ?? ??? ???????? ?? ????? ????

?? ?????? ??????? ?????? ?? ??? ??? ??? ????? ???????? ???? ??? ???? ??????? ?????? ??? "?????? 18 1996, ??." ?? ???? ??
Sub InsertDateTimeMethod()
   Dim MyRange As Object
   Set MyRange = Selection.Range
   ' Selection Example:
   Selection.InsertDateTime DateTimeFormat:="MMMM dd, yyyy", _
   InsertAsField:=True
   ' Range Example:
   MyRange.InsertDateTime DateTimeFormat:="MMM dd, yyyy", _
   InsertAsField:=True
End Sub
				

??? ??? ???????? ?? ???????? ???? ?? ??? ?????? ?? ??? ???????? ?? ????? ????

?? ?????? ??????? ????? ?? ??????? ?????? ?? ???? ?? ??? ???????? ?? ???????? ???? ???
Sub InsertParagraphMethod()
   Dim MyRange As Object
   Set MyRange = ActiveDocument.Range
   ' Selection Example:
   Selection.InsertParagraph
   ' Range Example:
   MyRange.Collapse Direction:=wdCollapseStart
   MyRange.InsertParagraph
End Sub
				

?? ?????? ???????? ???? ?? ??? ?????? ?? ??? ???????? ?? ????? ????

?? ?????? ??????? ????? ?? ???-headed ??? ???????? ???? ???
Sub InsertSymbolMethod()
   Dim MyRange As Object
   Set MyRange = ActiveDocument.Range
   ' Selection Example:
   Selection.InsertSymbol CharacterNumber:=171, _
      Font:="Symbol", Unicode:=False
   ' Range Example:
   MyRange.Collapse Direction:=wdCollapseStart
   MyRange.InsertSymbol CharacterNumber:=171, _
      Font:="Symbol", Unicode:=False
End Sub
				

?????????? ?? ??????? ?? ??? ?????? ?? ??? ???????? ?? ????? ????

?? ?????? ??? ??????? ????? ?? ??????? ?????? ?? ?????????? ?? ??? ?? ???????? ???? ???
Sub PasteMethod()
   Dim MyRange As Object
   Set MyRange = Selection.Range
   ' Selection Example:
   Selection.Paste
   ' Range Example:
   MyRange.Collapse Direction:=wdCollapseStart
   MyRange.Paste
End Sub
				

?????? ???????? Visual Basic Editor ??? ????? ?? ???? ??? ???? ??????? ?? ??? ????? ????Microsoft Visual Basic ??????????? ???????????, ???????????? ????????Office ????? ?? ????? ????????, ?? ???? ?????????? ?? ??????

Visual Basic Editor ??? ??? ???????? ?? ????? ???? ?? ???? ??? ???? ??????? ?? ??? ????? ????Microsoft Visual Basic ??????????? ???????????, ?????????????? ?? ???Office ????? ?? ????? ????????, ?? ???? ?????????? ?? ??????

?? ??? ??? ????? ??? ?? ????? ???? ???? ?? ???? ??? ???? ??????? ?? ??? Microsoft ???????? ??? ???? ????? ?? ??? ????? ???? ?????? ?? ????? ????:
212536  (http://support.microsoft.com/kb/212536/EN-US/ ) OFF2000: ???? ???????? ???? ?? ????? ??? ?? ?????

??????

??????????? ?? ??? Visual Basic ?? ??? ??? ??????? ???? ?? ???? ??? ???? ??????? ?? ??? ????? ?????????? ???? ?? Microsoft ???????? ??? ?????:
226118  (http://support.microsoft.com/kb/226118/EN-US/ ) OFF2000: ???????????? ?????? Visual Basic ?? ??? ????????? ?? ???

???? ???? ???? ??:
  • Microsoft Word 2000 Standard Edition
??????: 
kbdtacode kbhowto kbmacroexample kbprogramming kbmt KB212682 KbMthi
???? ?????? ???????????? ?????? ????????
??????????: ?? ???? ?? ???? ??????? ?? ????? ?? Microsoft ????-?????? ?????????? ?????? ?????? ???? ??? ??. Microsoft ???? ??? ????-???????? ?? ????-???????? ????? ?????? ?? ???? ???????? ???? ?? ???? ????? ????? ??? ?? ??? ?????? ?? ???? ???? ???? ??? ????? ??. ???????, ????-???????? ???? ????? ???? ???? ???? ???. ?????, ????????, ?????-???? ?? ??????? ?? ???????? ?? ???? ???, ???? ?? ??? ?????? ???? ???? ??? ????? ??? ?? ???? ??. Microsoft ??????? ??? ???? ?? ?????? ?? ??????????, ????????? ?? ??? ?????? ?? ???? ????? ?? ???? ???????? ?? ??? ???? ????? ?? ??? ????????? ???? ??. Microsoft ????-?????? ?????????? ?? ????? ?????? ?? ?? ??? ??.
?????????? ?? ??????? ????????? ??????? ??:212682  (http://support.microsoft.com/kb/212682/en-us/ )