Scripting the MS Office Visual Basic Editor

Hello All –

Continuing on a chore first started in April 2021, I’m trying to position the windows of the Excel and Word visual basic editors. I stalled out using VBA so I’m giving Applescript a go. My problem for now is how to handle UI elements that throw an error. Here is an example. The window is named “Project - VBA Project” AKA window “Project - VBAProject” of window “Microsoft Visual Basic - VBE Windows.xlsb” of application process “Microsoft Excel” to quote Script Debugger, hereafter SDB.

When I look at its class SDB says: “Error getting class: no such object” (should be window)

When I look at its name SDB says: “Error getting name: no such object” (should be “Project - VBA Project”)

And when I look at its title SDB says: “Error getting title: no such object” (should also be “Project - VBA Project”)

Basically, all the properties and elements of the sub-windows throw errors, Yet somehow SDB works around it (see the AKA above.) How is it doing this? Beyond the property examples shown, I also want to read and write to size and position.

I tried to write to class, but couldn’t, presumably in accordance with the crossed-out pencil. I captured the window names by hacking the error messages, but I can’t make them do anything, like resize and move. :sunglasses:

Thanks for reading, Mick

Unless there is a sly way to write to “readonly” properties (there really shouldn’t be) I don’t think this can be done by Applescript, unless I can code dragging the windows around. Not holding my breath.

ChatGPT gave me a way using Windows APIs. That doesn’t help of course, and its Applescript code didn’t work.

…Mick