Network Security Internet Technology Development Database Servers Mobile Phone Android Software Apple Software Computer Software News IT Information

In addition to Weibo, there is also WeChat

Please pay attention

WeChat public account

Shulou

How does VB.NET operate Word

2025-04-01 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Development >

Share

Shulou(Shulou.com)06/02 Report--

This article will explain in detail how to operate Word in VB.NET. The content of the article is of high quality, so the editor shares it for you as a reference. I hope you will have a certain understanding of the relevant knowledge after reading this article.

If you want to be a good programmer, you have to study every day to increase your knowledge base so as not to be eliminated by technology. So for the study of VB.NET, the same is true, there can not be a moment's rest. So today I will bring you some experience of VB.NET operating Word to help you learn.

VB.NET operates on 1 of Word, adding microsoft word 9.0 object library to project\ references

VB.NET operates Word 2 to start word

Dim wApp As Word.Application Set wApp = New Word.Application wApp.Visible = True

Close word

WApp.Quit Set wApp = Nothing

VB.NET operates Word 3 to open the file

Set wDoc = Documents.Add (New) ActiveDocument.SaveAs Text1.Text (Save) Set wDoc = Documents.Open (FileName:=Text1.Text) (Open specified file)

The above Documents and ActiveDocument are instantiated objects in word object, that is, objects that can be used without set obj=new obj. Like app, debug, err and other objects in vb

After the file is opened, get the cursor location mySelection to add all kinds of data (text, image, table, etc.) to the file.

VB.NET operates Word 4, inserting text

Dim mySelection As Word.Selection Set mySelection = Documents.Application.Selection

Note the above two lines of code, as long as you have these two lines of code, you can use all the macro operations in word. 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

It is necessary to mention the importance of macro in word programming. Almost all word operations can be implemented programmatically as long as you can implement them through word.

VB.NET manipulates Word 5 to insert an image

Documents.Application.Selection.InlineShapes.

AddPicture text1.text

VB.NET manipulates Word 6 and inserts tables

Because the ability to process tables in excel is stronger than that in word, you can generate tables in excel and then copy them to word

On how to operate VB.NET Word to share here, I hope that the above content can be of some help to you, can learn more knowledge. If you think the article is good, you can share it for more people to see.

Welcome to subscribe "Shulou Technology Information " to get latest news, interesting things and hot topics in the IT industry, and controls the hottest and latest Internet news, technology news and IT industry trends.

Views: 0

*The comments in the above article only represent the author's personal views and do not represent the views and positions of this website. If you have more insights, please feel free to contribute and share.

Share To

Development

Wechat

© 2024 shulou.com SLNews company. All rights reserved.

12
Report