Home > News content

In Word Node, Microsoft is how to replace the macro

via:博客园     time:2016/4/6 17:00:25     readed:2806

English text:Node Replaced Macros in Microsoft How Word

Over the last 30 years, the macro (macros) has become a key selling point for Word Microsoft. WordBASIC was first introduced in 1989, it can let received little training typist can computer programming, so as to simplify their daily work.

In that era, the competition was very fierce. In addition to Word, WordStar and WordPerfect have catch up from behind, their own macro programming language. With the continuous competition, more and more business users, the update has become very frequent.

In the late 90's of last century, some interesting things happened. Microsoft has created the visual basic for applications (VBA), the language with (limited) OOP ability and matched with the IDE, to replace the WordBASIC, it creates the and is not just another embedded components. Initially, Microsoft is expected to use this technology in all of the Office MS products, and then they realize that the technology can be licensed for certification. Soon, many of the companies have provided support for VBA, includingArcGIS,AutoCAD,SolidWorks,CorelDrawAnd evenWordPerfect.

In response, Microsoft locks the VBA programming interface. It is still very powerful, but the security feature is closed, so use it in fact very challenging. Most virus scanners reject all documents that are shared by email with macros.

.NET and Office

In order to get people to give up the outdated VBA technology, Microsoft also created Studio Tools for Office Visual (VSTO). This set of development tools and libraries can not only create the Office plug-in, but also allows independent applications to manipulate Office documents.

At least in theory. But in fact, in these two areas VSTO has failed.

In addition, there are versions of the problem. VBA style macros can be stored as plain text, which means that if you don't use only the new version of the feature, you can use any version of the code can be used in Office. While writing the VSTO plug-in, you need to program specific Office versions. This means that developers can only use the oldest version of the company.

On the other hand, professional developers are not much interested in plug-ins. They want to build servers that use and / or generate documents. VSTO based on COM automation, which means that before doing the actual work, the first to have a copy of Word or Excel. For each user of the Web site, to run a copy of a heavyweight desktop application, this approach is clearly not stand.

Similar to VBA, we can't actually use VSTO on a browser based Web processor.

Construction of Office using Add-In Node

As we mentioned earlier, JavaScript has now become a common programming language. Amateurs (as well as similar professional developers) do not want or do not like heavyweight IDE, such as Eclipse or Studio Visual, so Node into their development platform. So, Microsoft chose these tools to build add-in Office, we should not be surprised.

First of all, we need to install Node. And then run the following two commands from the command line:

Install -g TSD bower NPM gulp yo generator-office yo Office

Generator yeoman will ask us what type of add-in we want to build ribbon (command task, pane, etc.), which support Office products and want to use Angular or pure HTML/JavaScript to build. The next command to execute is to build a local server to host your add-in.

Serve-static gulp

This is for the basic smoke test, for the actual environment, you need to run on Office Web. After opening an empty document, you can upload manifest add-in, and then look at its actual effect.

You might ask, since you want to upload manifest, why would you want to start the local server? This is because the manifest in your computer runs Office at the same time, it allows the browser to load add-in from the computer. In practice, this means that you can modify the add-in, click on the browser's refresh button, you can see the actual effect immediately, do not need to re upload add-in after each change.

Because this is a Web application, you can use the browser built-in debugging tools for debugging.

To see the actual effect of words, you can watch the Shapley HarrisonOffice Add-ins with Any Build Code Editor and Office Onlinedemonstration。

China IT News APP

Download China IT News APP

Please rate this news

The average score will be displayed after you score.

Post comment

Do not see clearly? Click for a new code.

User comments