Copy Word Macros from One Document to Other using Aspose.Words for Java 19.12

Copy Word macros in Java using Aspose.Words

Another month, another feature-rich release! Aspose.Words for Java 19.12 has been rolled out with a bunch of useful features, enhancements and bug fixes. Using the latest release you will be able to copy Word macros from one document to another by cloning the VBA module or the VBA project in Java. Furthermore, we have added the support of PDF 1.7 Standard for Word to PDF conversion. Also, the latest release of Aspose.Words for Java is capable of scanning user-installed fonts in Windows 10 for the font source. So let’s go through these useful features in more detail.

Copy VBA Macros from One Word Document to Other in Java

Macros in a Word document are written in VBA (Visual Basic for Applications) to automate the frequently used tasks. MS Word macros contain a set of code statements that are executed when a particular button in the toolbar is clicked or a combination of keys is pressed.

In the previous release of Aspose.Words for Java, we introduced the feature of adding macros to VBA project or VBA modules in the Word documents. However, there could be the case when you need to clone VBA modules or the whole VBA project to copy Word macros from one document to another programmatically. In order to make it possible, we have added deepClone() method to VABModule and VBAProject classes to copy Word macros from a particular VBA module or project.

Let’s now check out how to copy Word macros from one document to another in Java using Aspose.Words for Java.

Cloning VBA Module

The following Java code sample shows how to copy macros by cloning a particular VBA module in Word document.

Cloning VBA Project

The following Java code sample shows how to copy macros by cloning a complete VBA project in Word document.

Convert Word to PDF 1.7 Standard

A PDF document may compliant with various standards or editions of PDF specifications. PDF 1.7 was the sixth edition of the PDF specification and it included some proprietary technologies which are defined only by Adobe. Aspose.Words for Java already supports Word to PDF conversion, however, we have extended this support and now you can convert a Word document to PDF 1.7. For this, we have added PDF_17 option to the PdfCompliance enum.

The following Java code sample shows how to convert Word to PDF by specifying PdfCompliance.

Using User-Installed Fonts for SystemFontSource on Windows 10

In the previous versions of the Aspose.Words for Java, the API used to scan only the system-installed fonts for SystemFontSource. This approach didn’t fit well in Windows 10 where the fonts may be installed either into the system folder “%windir%\fonts” for all users or into the user folder “%userprofile%\AppData\Local\Microsoft\Windows\Fonts” for the current user. We have enhanced this feature and now Aspose.Words for Java has the ability to scan the user-installed fonts as well.

New Find and Replace Option

Aspose.Words for Java provides Find and Replace option to replace the desired words or phrases in the Word documents. In the previous versions of the API, the find/replace feature used to analyze the text boxes separately from the content of the document. This behavior was designed in accordance with the MS Word’s behavior, however, there could be the case when you may need to find and replace content sequentially including the text in the text boxes. For such a scenario, we have introduced a new option in FindReplaceOptions class as UseLegacyOrder. The following Java code sample shows how to use this option when finding and replacing text in a Word document.

Well, this was a brief overview of some of the important features we have added to the latest release. You can have a look at the complete list of features and bug fixes in the release notes. You can download the latest release and evaluate the new features by yourself. For more details about any feature, you may consult the documentation of the API as well as contact us via our forum.