Summary of Word Programming in VB6

Source: Internet
Author: User
Tags implement
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

5, insert Image
Documents.Application.Selection.InlineShapes.AddPicture Text1.Text

6, insert the table
Because Excel has more ability to work with tables than Word does, you can create tables in Excel and then copy them into Word




Contact Us

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.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.