VbaReferenceType

Inheritance: java.lang.Object

public class VbaReferenceType

Allows to specify the type of a VbaReference object.

Examples:

Shows how to get/remove an element from the VBA reference collection.


 public void removeVbaReference() throws Exception {
     final String BROKEN_PATH = "X:\\broken.dll";
     Document doc = new Document(getMyDir() + "VBA project.docm");

     VbaReferenceCollection references = doc.getVbaProject().getReferences();
     Assert.assertEquals(5, references.getCount());

     for (int i = references.getCount() - 1; i >= 0; i--) {
         VbaReference reference = doc.getVbaProject().getReferences().get(i);
         String path = getLibIdPath(reference);

         if (BROKEN_PATH.equals(path))
             references.removeAt(i);
     }
     Assert.assertEquals(4, references.getCount());

     references.remove(references.get(1));
     Assert.assertEquals(3, references.getCount());

     doc.save(getArtifactsDir() + "VbaProject.RemoveVbaReference.docm");
 }

 /// 
 /// Returns string representing LibId path of a specified reference.
 /// 
 private static String getLibIdPath(VbaReference reference) {
     switch (reference.getType()) {
         case VbaReferenceType.REGISTERED:
         case VbaReferenceType.ORIGINAL:
         case VbaReferenceType.CONTROL:
             return getLibIdReferencePath(reference.getLibId());
         case VbaReferenceType.PROJECT:
             return getLibIdProjectPath(reference.getLibId());
         default:
             throw new IllegalArgumentException();
     }
 }

 /// 
 /// Returns path from a specified identifier of an Automation type library.
 /// 
 private static String getLibIdReferencePath(String libIdReference) {
     if (libIdReference != null) {
         String[] refParts = libIdReference.split("#");
         if (refParts.length > 3)
             return refParts[3];
     }

     return "";
 }

 /// 
 /// Returns path from a specified identifier of an Automation type library.
 /// 
 private static String getLibIdProjectPath(String libIdProject) {
     return libIdProject != null ? libIdProject.substring(3) : "";
 }
 

Fields

FieldDescription
CONTROLSpecifies a twiddled type library reference type.
ORIGINALSpecifies an original Automation type library reference type.
PROJECTSpecified an external VBA project reference type.
REGISTEREDSpecifies an Automation type library reference type.
length

Methods

MethodDescription
fromName(String vbaReferenceTypeName)
getName(int vbaReferenceType)
getValues()
toString(int vbaReferenceType)

CONTROL

public static int CONTROL

Specifies a twiddled type library reference type.

Remarks:

This type corresponds to 2.3.4.2.2.3 REFERENCECONTROL Record of [MS-OVBA]: https://docs.microsoft.com/en-us/openspecs/office_file_formats/ms-ovba/d64485fa-8562-4726-9c5e-11e8f01a81c0

ORIGINAL

public static int ORIGINAL

Specifies an original Automation type library reference type.

Remarks:

This type corresponds to 2.3.4.2.2.4 REFERENCEORIGINAL Record of [MS-OVBA]: https://docs.microsoft.com/en-us/openspecs/office_file_formats/ms-ovba/3ba66994-8c7a-4634-b2da-f9331ace6686

PROJECT

public static int PROJECT

Specified an external VBA project reference type.

Remarks:

This type corresponds to 2.3.4.2.2.6 REFERENCEPROJECT Record of [MS-OVBA]: https://docs.microsoft.com/en-us/openspecs/office_file_formats/ms-ovba/08280eb0-d628-495c-867f-5985ed020142

REGISTERED

public static int REGISTERED

Specifies an Automation type library reference type.

Remarks:

This type corresponds to 2.3.4.2.2.5 REFERENCEREGISTERED Record of [MS-OVBA]: https://docs.microsoft.com/en-us/openspecs/office_file_formats/ms-ovba/6c39388e-96f5-4b93-b90a-ae625a063fcf

length

public static int length

fromName(String vbaReferenceTypeName)

public static int fromName(String vbaReferenceTypeName)

Parameters:

ParameterTypeDescription
vbaReferenceTypeNamejava.lang.String

Returns: int

getName(int vbaReferenceType)

public static String getName(int vbaReferenceType)

Parameters:

ParameterTypeDescription
vbaReferenceTypeint

Returns: java.lang.String

getValues()

public static int[] getValues()

Returns: int[]

toString(int vbaReferenceType)

public static String toString(int vbaReferenceType)

Parameters:

ParameterTypeDescription
vbaReferenceTypeint

Returns: java.lang.String