com.aspose.words

Class VbaProject

  • java.lang.Object
    • com.aspose.words.VbaProject
  • All Implemented Interfaces:
    java.lang.Cloneable
    public class VbaProject 
    extends java.lang.Object

Provides access to VBA project information. A VBA project inside the document is defined as a collection of VBA modules.

Example:

Shows how to get access to VBA project information in the document.
Document doc = new Document(getMyDir() + "Document.TestButton.docm");

// A VBA project inside the document is defined as a collection of VBA modules
VbaProject vbaProject = doc.getVbaProject();

VbaModuleCollection vbaModules = doc.getVbaProject().getModules();
for (VbaModule module : vbaModules) {
    System.out.println(MessageFormat.format("Module name: {0};\nModule code:\n{1}\n", module.getName(), module.getSourceCode()));
}

// Set new source code for VBA module
String oldCode = vbaModules.get(0).getSourceCode();
vbaModules.get(0).setSourceCode("Your VBA code...");

vbaModules.get(0).setSourceCode(oldCode);

Constructor Summary
VbaProject()
Creates a blank VbaProject.
 
Property Getters/Setters Summary
intgetCodePage()
Returns the VBA project’s code page.
booleanisSigned()
Shows whether the VbaProject is signed or not.
VbaModuleCollectiongetModules()
Returns collection of VBA project modules.
java.lang.StringgetName()
void
setName(java.lang.Stringvalue)
           Gets or sets VBA project name.
 
Method Summary
VbaProjectdeepClone()
Performs a copy of the VbaProject.
 

    • Constructor Detail

      • VbaProject

        public VbaProject()
        Creates a blank VbaProject.
    • Property Getters/Setters Detail

      • getCodePage

        public int getCodePage()
        
        Returns the VBA project’s code page.
      • isSigned

        public boolean isSigned()
        
        Shows whether the VbaProject is signed or not.
      • getModules

        public VbaModuleCollection getModules()
        
        Returns collection of VBA project modules.

        Example:

        Shows how to get access to VBA project information in the document.
        Document doc = new Document(getMyDir() + "Document.TestButton.docm");
        
        // A VBA project inside the document is defined as a collection of VBA modules
        VbaProject vbaProject = doc.getVbaProject();
        
        VbaModuleCollection vbaModules = doc.getVbaProject().getModules();
        for (VbaModule module : vbaModules) {
            System.out.println(MessageFormat.format("Module name: {0};\nModule code:\n{1}\n", module.getName(), module.getSourceCode()));
        }
        
        // Set new source code for VBA module
        String oldCode = vbaModules.get(0).getSourceCode();
        vbaModules.get(0).setSourceCode("Your VBA code...");
        
        vbaModules.get(0).setSourceCode(oldCode);
      • getName/setName

        public java.lang.String getName() / public void setName(java.lang.String value)
        
        Gets or sets VBA project name.

        Example:

        Shows how to get access to VBA project information in the document.
        Document doc = new Document(getMyDir() + "Document.TestButton.docm");
        
        // A VBA project inside the document is defined as a collection of VBA modules
        VbaProject vbaProject = doc.getVbaProject();
        
        VbaModuleCollection vbaModules = doc.getVbaProject().getModules();
        for (VbaModule module : vbaModules) {
            System.out.println(MessageFormat.format("Module name: {0};\nModule code:\n{1}\n", module.getName(), module.getSourceCode()));
        }
        
        // Set new source code for VBA module
        String oldCode = vbaModules.get(0).getSourceCode();
        vbaModules.get(0).setSourceCode("Your VBA code...");
        
        vbaModules.get(0).setSourceCode(oldCode);
    • Method Detail

      • deepClone

        public VbaProject deepClone()
        Performs a copy of the VbaProject.
        Returns:
        The cloned VbaProject.