Jump to content
Macro Express Forums

External Scripts for Microsoft Word


Recommended Posts

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:

 

image.thumb.png.08c5b8f21c7bfdb0b29d5eb625aafa20.png

 

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!

Link to comment
Share on other sites

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. 

 

 

Link to comment
Share on other sites

  • 3 weeks later...

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. 

Link to comment
Share on other sites

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!

Link to comment
Share on other sites

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

Loading...
×
×
  • Create New...