Apply VBA Word Macro - From Another Document To Active Document - Com
Posted: 25 Mar 2017, 21:18
Hi Autohotkey experts,
I am looking for some help, I am a newbie as of yesterday.
I am trying to apply a vba word macro that is stored in a different file.
Example
C:\Users\Home\Desktop\Highlightmacros.docm
has a macro named "yellowparagraphs" stored in it.
How can I access and apply this macro to my current active document?
I know the obvious solution is to copy it to my normal.dotm but that is not what I am looking for.
I just want to apply the macro stored in that file to my active document when i am editing.
I referenced this below and read all the com tutorials found here but I don't know how to do this and the below gives me an error
Directory = L:\Today
Filename := " " Directory "\Test.rtf" ;Path of File
MacroName = PrtAF10851 ; name of the existing MSWord Macro
COM_Init()
Word := COM_CreateObject("Word.Application")
COM_Invoke(Word,"Visible=",False)
Docs :=
COM_Invoke(Word,"Documents")
COM_Invoke(Docs,"Open",Filename)
COM_Invoke(Word, "Run", "!"MacroName)
COM_Release("!"MacroName)
COM_Release(Docs)
COM_Release(Word)
COM_Term()
Sleep 2000
From <https://autohotkey.com/board/topic/4637 ... ro-by-ahk/>
please can an expert help me thank you very much
sarah
I am looking for some help, I am a newbie as of yesterday.
I am trying to apply a vba word macro that is stored in a different file.
Example
C:\Users\Home\Desktop\Highlightmacros.docm
has a macro named "yellowparagraphs" stored in it.
How can I access and apply this macro to my current active document?
I know the obvious solution is to copy it to my normal.dotm but that is not what I am looking for.
I just want to apply the macro stored in that file to my active document when i am editing.
I referenced this below and read all the com tutorials found here but I don't know how to do this and the below gives me an error
Directory = L:\Today
Filename := " " Directory "\Test.rtf" ;Path of File
MacroName = PrtAF10851 ; name of the existing MSWord Macro
COM_Init()
Word := COM_CreateObject("Word.Application")
COM_Invoke(Word,"Visible=",False)
Docs :=
COM_Invoke(Word,"Documents")
COM_Invoke(Docs,"Open",Filename)
COM_Invoke(Word, "Run", "!"MacroName)
COM_Release("!"MacroName)
COM_Release(Docs)
COM_Release(Word)
COM_Term()
Sleep 2000
From <https://autohotkey.com/board/topic/4637 ... ro-by-ahk/>
please can an expert help me thank you very much
sarah