Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Proposed new method in ActiveXComponent #41

Open
EJP286CRSKW opened this issue Sep 21, 2023 · 1 comment
Open

Proposed new method in ActiveXComponent #41

EJP286CRSKW opened this issue Sep 21, 2023 · 1 comment

Comments

@EJP286CRSKW
Copy link

Some of the Item properteis in Excel VBA objects take parameters, believe it or not. The following additional method is proposed in ActiveXComponet to allow for this. Tested extensively.

    /**
     * Return a property with parameters.
     * <p>
     * This is required by some of the Excel VBA objects' Item properties.
     *
     * @param propertyName Property name
     * @param args Arguments
	 * @return Dispatch representing the object under the property name
     */
    public ActiveXComponent getPropertyAsComponent(String propertyName, Variant...args)
    {
        if (args == null || args.length == 0)
            return getPropertyAsComponent(propertyName);
        return new ActiveXComponent
            (
                Dispatch
                .invoke
                (
                    this,
                    propertyName,
                    Dispatch.Get,
                    args,
                    new int[args.length]
                ).getDispatch()
            )
            ;
    }

Example of usage, assuming we are in a Range class for the Excel VBA Range object, where Range extends ActiveXComponent:

    public Range    getCells(int row, int column)
    {
        return new Range(getPropertyAsComponent("Cells", new Variant(row), new Variant(column)));
    }
@freemansoft
Copy link
Owner

freemansoft commented Mar 18, 2024

Can you provide at test case to be added to verify it?

A test that that includes opening and closing Jacob?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants