Word| programming 1, adding Microsoft Word 9.0 Object Library in Project\references
2, Start Word
Dim Wapp as Word.Application
Set Wapp = New Word.Application
Wapp.visible = True
Close Word
Wapp.quit
Set Wapp = Nothing
3, open the file
Set Wdoc = Documents.Add (new)
Activedocument.saveas Text1.Text (Save)
Set Wdoc = Documents.Open (filename:=text1.text) (open specified file)
Both documents and ActiveDocument are instantiated objects in Word object, which are objects that can be used without set obj=new obj. Like the VB app, Debug, Err and other objects,
Once the file is open, get the cursor location myselection can add various data (text, images, tables, etc.) to the file.
4, inserting text
Dim Myselection as Word.selection
Set myselection = Documents.Application.Selection
' Notice the two lines of code above, and you can use all the macro actions in Word as long as you have these two lines of code. The following code is copied from the macro.
With Myselection
. InsertAfter Text1.Text & VbCrLf
. Font.Name = "Italics _gb2312"
. Font.Size = 16
. ParagraphFormat.Alignment = 1
End With
' There's a need to mention the importance of macro (macro) in Word programming, and almost all word operations, as long as you can implement it through word, can be programmed to implement
The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion;
products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the
content of the page makes you feel confusing, please write us an email, we will handle the problem
within 5 days after receiving your email.
If you find any instances of plagiarism from the community, please send an email to:
info-contact@alibabacloud.com
and provide relevant evidence. A staff member will contact you within 5 working days.