抄抄书,省得到处找
==========================
This code was written for Word 97 and worked fine for Word 2000.
No guarantees are given for any later versions of Word,
but most of this code will likely still be valid.
« A »
Array, ReDim an Array:
Array, Sort an Array:
« B »
Backspace:
Bookmark, Add:
Bookmark, Count # of Bookmarks in Document:
Bookmark, Delete:
Bookmark, Exists (Does It Exist?):
Bookmark, Go to Bookmark:
(This method does not work with bookmarks in Headers/Footers)
Bookmark, Select a Bookmark:
(This method works when using bookmarks in Headers/Footers)
Bookmark, Insert Text Using Range (Change Content of Range):
(This method works when using bookmarks in Headers/Footers)
Bookmark, Insert Text Using Range (Add After Range):
(This method works when using bookmarks in Headers/Footers)
Bookmark, Go to a Bookmark, replace the text that's contained
in the Bookmark, and still have the text bookmarked:
Bookmark, Replace Text of a Bookmark in document2 With the
Text of a Bookmark in document1:
Note that both documents must be open when the macro is run.
Bookmark, Turn Off View Bookmarks:
« C »
Call, Run a Macro That's in Another Template:
Call, Run a Macro That's Within the Same Template:
Caption, Load an Array Element Into an Option Box Caption:
CHR (Character) Function:
ComboBox, Add Array Items to Combo Box:
ComboBox, Set First Value to Show in Combo Box From an Array:
Constant, Declare a Constant:
Copy Entire Document:
Copy:
« D »
Delete:
Directory, Exists:
This particular code determines whether your computer has a C:\Windows\Temp
directory (you are running Windows) or a C:\WINNT\Temp directory (you are
running NT); of course, you can use this function to determine whether any
directory exists (for example, if SomeDir exists, great; elseif SomeDir
doesn't exist, then create it, etc.)
Document Variable, Set (Create) a Document Variable
(NOTE: This refers to a Word Document Variable, as opposed to
a Variable used in computer programming):
Document Variable, Create Draft# Doc Variable if Does Not Yet Exist
& Set Document, Draft # to 1 (NOTE: This refers to a Word Document
Variable, as opposed to a Variable used in computer programming):
Document Variable, What is the Current DocumentType Document Variable
Set To? (NOTE: This refers to a Word Document Variable, as opposed to
a Variable used in computer programming)
Document Variable, Check Document Variable Value (NOTE: This refers
to a Word Document Variable, as opposed to a Variable used in computer
programming):
Document, Go to Start of Document:
Document, Go to End of Document:
Document, New, Create a New Document from Another
Document (Template, Form Document, etc.):
Document, Protect Document:
Document, Save Document:
Document, SaveAs
Document, SaveAs (with all the junk):
Document, Unprotect Document:
« E »
Extend, Turn Off Extend Mode:
« F »
Field Code, Lock Field Code:
Field Code, Insert SEQ Field Code:
Field Code, Reset SEQ Field Code to Zero (Restart #ing):
Field Code, Sequence Numbering Field Codes With Sub-Levels:
Field Code, SEQ#, Reset #s to 0:
Field Code, Unlock Field Code:
Field Code, Update Field Code:
Field Code, View Field Codes:
Field Code, View Field Codes (with all the junk):
Find:
Find, Was It Found? (version 1)
Find, Was It Found? (version 2, thanks to Shawn Wilson)
Find, Field Code:
Find, Paragraph Mark (Real Paragraph, Not the Symbol):
Find, Replace:
Find, Replace Hard Returns With Manual Line Breaks
Within Selected Text:
Font, Set Font Size:
Font:
Footer, View Footer:
Form, Hide a Form:
Form, Load & Show a Form:
« G »
GoTo, Go to Bookmark:
(This method not suggested for use with bookmarks in Headers/Footers;
see "Bookmarks" entries under "B")
GoTo, Go to Page 1
« H »
Header, View Current Page Header:
Header, View Header (with all the junk):
« I »
IF Test:
Indent, Set Left Indent:
Indent, Set Right Indent:
InputBox, Get & Use Data From an Input Box:
Insert After:
Insert an Underlined Tab:
Insert AutoText:
Insert Date Code (Month Only):
Insert Date Code (Year Only):
Insert File:
Insert Page Break:
Insert Paragraph Symbol:
Insert Section Symbol:
Insert SEQ# Field Code:
Insert Text in Upper Case:
Insert Symbol:
Insert Tab:
Insert Text (replaces selection if anything is selected):
Insert Text After Position of Cursor (does not replace
selection; appends text to end of selection:
Insert Various Characters:
Insert, Type Paragraph:
« J »
« K »
« L »
Line, Beginning of Line:
Line, End of Line:
Line Spacing, Set Line Spacing to Exactly:
Loop: Do...Loop:
Loop: Do Until End of Document
Do Until ActiveDocument.Bookmarks("\Sel") = _Loop: Do a Search, Then Execute Some Other Commands
Inside a "Do Until End of Document" Loop (version 1):
Loop: Do a Search, Then Execute Some Other Commands Inside
a "Do Until End of Document" Loop (version 2, thanks to Shawn Wilson):
Loop: Do a Search, Then Execute Some Other Commands Inside a
"Do Until End of Document" Loop (version 3, thanks to Shawn Wilson):
« M »
Macro, Run a Macro That's in Another Template:
Macro, Run a Macro That's Within the Same Template:
Move Right, 1 Cell in a Table:
Move Right, a Few Cells in a Table:
Move Right, With Extend On:
Move Right:
Move Up One Paragraph:
MsgBox Result:
MsgBox, Use the MsgBox Result:
« N »
Number, Is Selected Text a Number? (IsNumeric function)
Number of Pages, Determine # Pages in Document:
« O »
« P »
Paragraph, Justify Paragraph:
Paragraph, KeepLinesTogether:
Paragraph, KeepWithNext:
Paragraph, Space After:
Paragraph, Space Before:
Paragraph, WidowOn:
Paste:
Properties, Set Properties On the Fly:
« Q »
« R »
Run a Macro That's in Another Template:
Run a Macro That's Within the Same Template:
« S »
Select, All (Entire Document):
Select, Entire Line:
Select, Entire Line (Except Paragraph Mark):
Select, Text, Using Extend:
Smart Cut & Paste Off:
Smart Quotes, Turn On "Smart Quotes As-You-Type":
Start of Line:
Style, Copy Style Using Organizer:
Style, Set a Style:
« T »
Table of Contents, Update Page Numbers Only:
Table, Go to 1st Table in Document:
Table, Show Table Gridlines:
Table, Take Borders Off Table:
Table, Total the Numbers
Tabs, Clear All:
Tabs, Tab Stop, Add:
TextBox, Is There Something in a Text Box:
Text File, Open, Write to & Close:
Text File, Open, Read Data Into Variables & Close:
This example assumes that "C:\Temp\MyFile.txt" is a text file with a few
lines of text in it, each line containing a string in quotations and a
number separated by a comma. For example:
"Howdy Doodie", 12345
"Good Morning", 67890
« U »
Underline, Turn On Single Underline:
Underline, Turn Off Single Underline:
Unload Forms - Unload All of Them (i.e., at End of Program):
User Info, Set User Initials in Tools, User Info:
User Info, Set User Name in Tools, User Info:
« V »
Value, Get Value of a Number From a String:
Variable, Declare:
View, Bookmarks:
View, Current Page Header:
View, Field Codes (with all the junk):
View, Field Codes:
View, Footer:
View, Header:
View, Header (with all the junk):
View, Main View (Close Header or Footer:)
View, Options:
View, Turn Off View Bookmarks:
« W »
Window, Maximize Application Window:
« X »
« Y »
« Z »