acantor Posted March 6, 2022 Report Share Posted March 6, 2022 I use a Word VBA macro for changing the highlight colour to yellow: Sub PaintYellow() Selection.Range.HighlightColorIndex = wdYellow End Sub Is it possible to invoke this code from Macro Express using its "External Script" feature? From MEP Help, I think the solution may be something like this: When I run the Macro Express macro, the text variable %Console% contains this: Quote C:\Users\Alan\AppData\Local\Temp\mxescr9.vbs(1, 1) Microsoft VBScript compilation error: Expected statement Not only do I not understand the error message, I don't even know if I'm on the right track! Quote Link to comment Share on other sites More sharing options...
Cory Posted March 6, 2022 Report Share Posted March 6, 2022 Does that script work by itself? I thought one must execute macro code from within the app. I didn't think you could run them externally. For things like this I use Interop, but that needs to be executed in a .NET program. It's like a MEP for Office apps. Most of the commands are doing things as one might command a user to do them. It's not an MEP thing so if you're interested, PM me. Quote Link to comment Share on other sites More sharing options...
acantor Posted March 6, 2022 Author Report Share Posted March 6, 2022 That cryptic message appears when I run my MEP script within Word. What I'm hoping to do is to trigger VBA scripts for Word via Macro Express. Quote Link to comment Share on other sites More sharing options...
Cory Posted March 23, 2022 Report Share Posted March 23, 2022 I don't think it works the way you're thinking. MEP isn't in Word. You can't run VBA in a Word instance that way, it needs to be in a module attached to the document. You could add button in Word to run the macro. Or if you wanted to have a pop up menu, you could have it fire a hotkey you established for that VBA macro. This article shows you how to assign a hotkey or button in Word to fire a macro. Quote Link to comment Share on other sites More sharing options...
acantor Posted March 23, 2022 Author Report Share Posted March 23, 2022 39 minutes ago, Cory said: I don't think it works the way you're thinking. MEP isn't in Word. You can't run VBA in a Word instance that way, it needs to be in a module attached to the document. Hi Cory, I'm coming to the same conclusion. I had hoped the Macro Express External Script feature would make it possible to interact programmatically with applications like Word, as one can do with AutoHotkey. It would appear we Macro Express users must use indirect methods to trigger Word commands. At least we can do that! Quote Link to comment Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.