public class VbaProject
Example:
Shows how to access a document's VBA project information.Document doc = new Document(getMyDir() + "VBA project.docm"); // A VBA project contains a collection of VBA modules. VbaProject vbaProject = doc.getVbaProject(); System.out.println(vbaProject.isSigned() ? MessageFormat.format("Project name: {0} signed; Project code page: {1}; Modules count: {2}\n", vbaProject.getName(), vbaProject.getCodePage(), vbaProject.getModules().getCount()) : MessageFormat.format("Project name: {0} not signed; Project code page: {1}; Modules count: {2}\n", vbaProject.getName(), vbaProject.getCodePage(), vbaProject.getModules().getCount())); VbaModuleCollection vbaModules = doc.getVbaProject().getModules(); Assert.assertEquals(vbaModules.getCount(), 3); 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. You can access VBA modules in the collection either by index or by name. vbaModules.get(0).setSourceCode("Your VBA code..."); vbaModules.get("Module1").setSourceCode("Your VBA code..."); // Remove a module from the collection. vbaModules.remove(vbaModules.get(2));
Constructor Summary |
---|
VbaProject()
Creates a blank VbaProject. |
Property Getters/Setters Summary | ||
---|---|---|
int | getCodePage() | |
Returns the VBA project’s code page.
|
||
boolean | isSigned() | |
Shows whether the VbaProject is signed or not.
|
||
VbaModuleCollection | getModules() | |
Returns collection of VBA project modules.
|
||
java.lang.String | getName() | |
void | setName(java.lang.Stringvalue) | |
Gets or sets VBA project name. | ||
VbaReferenceCollection | getReferences() | |
Gets a collection of VBA project references.
|
Method Summary | ||
---|---|---|
VbaProject | deepClone() | |
Performs a copy of the |
public int getCodePage()
Example:
Shows how to access a document's VBA project information.Document doc = new Document(getMyDir() + "VBA project.docm"); // A VBA project contains a collection of VBA modules. VbaProject vbaProject = doc.getVbaProject(); System.out.println(vbaProject.isSigned() ? MessageFormat.format("Project name: {0} signed; Project code page: {1}; Modules count: {2}\n", vbaProject.getName(), vbaProject.getCodePage(), vbaProject.getModules().getCount()) : MessageFormat.format("Project name: {0} not signed; Project code page: {1}; Modules count: {2}\n", vbaProject.getName(), vbaProject.getCodePage(), vbaProject.getModules().getCount())); VbaModuleCollection vbaModules = doc.getVbaProject().getModules(); Assert.assertEquals(vbaModules.getCount(), 3); 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. You can access VBA modules in the collection either by index or by name. vbaModules.get(0).setSourceCode("Your VBA code..."); vbaModules.get("Module1").setSourceCode("Your VBA code..."); // Remove a module from the collection. vbaModules.remove(vbaModules.get(2));
public boolean isSigned()
Example:
Shows how to access a document's VBA project information.Document doc = new Document(getMyDir() + "VBA project.docm"); // A VBA project contains a collection of VBA modules. VbaProject vbaProject = doc.getVbaProject(); System.out.println(vbaProject.isSigned() ? MessageFormat.format("Project name: {0} signed; Project code page: {1}; Modules count: {2}\n", vbaProject.getName(), vbaProject.getCodePage(), vbaProject.getModules().getCount()) : MessageFormat.format("Project name: {0} not signed; Project code page: {1}; Modules count: {2}\n", vbaProject.getName(), vbaProject.getCodePage(), vbaProject.getModules().getCount())); VbaModuleCollection vbaModules = doc.getVbaProject().getModules(); Assert.assertEquals(vbaModules.getCount(), 3); 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. You can access VBA modules in the collection either by index or by name. vbaModules.get(0).setSourceCode("Your VBA code..."); vbaModules.get("Module1").setSourceCode("Your VBA code..."); // Remove a module from the collection. vbaModules.remove(vbaModules.get(2));
public VbaModuleCollection getModules()
Example:
Shows how to access a document's VBA project information.Document doc = new Document(getMyDir() + "VBA project.docm"); // A VBA project contains a collection of VBA modules. VbaProject vbaProject = doc.getVbaProject(); System.out.println(vbaProject.isSigned() ? MessageFormat.format("Project name: {0} signed; Project code page: {1}; Modules count: {2}\n", vbaProject.getName(), vbaProject.getCodePage(), vbaProject.getModules().getCount()) : MessageFormat.format("Project name: {0} not signed; Project code page: {1}; Modules count: {2}\n", vbaProject.getName(), vbaProject.getCodePage(), vbaProject.getModules().getCount())); VbaModuleCollection vbaModules = doc.getVbaProject().getModules(); Assert.assertEquals(vbaModules.getCount(), 3); 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. You can access VBA modules in the collection either by index or by name. vbaModules.get(0).setSourceCode("Your VBA code..."); vbaModules.get("Module1").setSourceCode("Your VBA code..."); // Remove a module from the collection. vbaModules.remove(vbaModules.get(2));
public java.lang.String getName() / public void setName(java.lang.String value)
Example:
Shows how to access a document's VBA project information.Document doc = new Document(getMyDir() + "VBA project.docm"); // A VBA project contains a collection of VBA modules. VbaProject vbaProject = doc.getVbaProject(); System.out.println(vbaProject.isSigned() ? MessageFormat.format("Project name: {0} signed; Project code page: {1}; Modules count: {2}\n", vbaProject.getName(), vbaProject.getCodePage(), vbaProject.getModules().getCount()) : MessageFormat.format("Project name: {0} not signed; Project code page: {1}; Modules count: {2}\n", vbaProject.getName(), vbaProject.getCodePage(), vbaProject.getModules().getCount())); VbaModuleCollection vbaModules = doc.getVbaProject().getModules(); Assert.assertEquals(vbaModules.getCount(), 3); 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. You can access VBA modules in the collection either by index or by name. vbaModules.get(0).setSourceCode("Your VBA code..."); vbaModules.get("Module1").setSourceCode("Your VBA code..."); // Remove a module from the collection. vbaModules.remove(vbaModules.get(2));
public VbaReferenceCollection getReferences()
public VbaProject deepClone()