Could you please options on triggering a word macro through AA? Similar to what we have for excel macro. Could you please advise

  • 4 October 2022
  • 3 replies

@Ashwin A.K​ 

3 replies

Userlevel 4
Badge +7

Hi @Rajesh Kulanthaivelu​ ,


I'm assuming that you want to perform Word Automation, but since we don't have a scope currently for Word to run macros with, you want to trigger them from Excel.


I've written something similar to this yesterday, and you can check it out if you are interested.


This can be done, but I would recommend keeping the Word non-macro enabled. Macro enabled word files don't communicate properly with Excel for some reason, and you will run into several issues when trying to trigger macros build in word, from Excel.


Here is an example of a macro built in excel which gets the job done on word:

Sub automateword()

Dim wdObj As Object, wdDoc As Object

Dim filePath As String


  filePath = File Path Goes Here

  Set wdObj = CreateObject("word.Application")

  wdObj.Visible = True

  wdObj.Documents.Open filePath, ReadOnly:=False


  'Word Automation goes here

  wdObj.Selection.TypeText Text:="Hello World!"


End Sub


Kind Regards,

Ashwin A.K

Thanks Ashwin. I will explore this option. Is there are any other option to trigger a word macro from AA? Like I read in one of the forums to create a hotkey shortcut for the word macro and then trigger it using keystrokes. Would you suggest if there is any challenge in using this approach or share alternate approaches, if any

Userlevel 4
Badge +7

Hi @Rajesh Kulanthaivelu​ 


You could probably turn that into a working solution, but the bot will wait for something to trigger it, whether it be file creation, deletion, or keystrokes i.e., something external to activate it.


The bot can't trigger itself i.e,, adding a keystroke after the bot starts listening for a trigger won't do the trick.


They way I see it, it looks like a lot of complexity, but there is no harm in exploring those options as well.


Kind Regards,

Ashwin A.K