Jump to content

Recommended Posts

Posted

hey guys,

is it possible to add automaticly a macro to a word file ?

i already saw the word udf (word.au3 standard include) but it didnt had any functions for it.

do you guys know a way ?

 

Best Regards,

 

Vivi

Posted

For Excel it works this way:

$oExcel.Application.VBE.ActiveVBProject.VBComponents.Import("C:\temp\Modul1.bas")

so I think for Word it should be similar:

$oWord.Application.VBE.ActiveVBProject.VBComponents.Import("C:\temp\Modul1.bas")

 

My UDFs and Tutorials:

  Reveal hidden contents

 

Posted
  On 2/20/2016 at 9:25 AM, water said:

For Excel it works this way:

$oExcel.Application.VBE.ActiveVBProject.VBComponents.Import("C:\temp\Modul1.bas")

so I think for Word it should be similar:

$oWord.Application.VBE.ActiveVBProject.VBComponents.Import("C:\temp\Modul1.bas")

 

Expand  

hugh vouch !

worked.

now i just need to make it silent :P

 

my code :

 

$word = ObjCreate("Word.Application")
$word.visible = False
$word.Documents.open(@ScriptDir & "/doc.doc")
$word.Application.VBE.ActiveVBProject.VBComponents.Import(@ScriptDir  & "/macro.txt")
$word.Application.Quit

 

 

NY6w2wR.png

Posted

Use the Word UDF that comes with AutoIt:

#include <Word.au3>

Global $oWord = _Word_Create()
Global $oDoc = _Word_DocOpen($oWord, @ScriptDir & "/doc.doc")
$oWord.Application.VBE.ActiveVBProject.VBComponents.Import(@ScriptDir  & "/macro.txt")
_Word_DocSave($oDoc)
_Word_DocClose($oDoc)
_Word_Quit($oWord)

 

My UDFs and Tutorials:

  Reveal hidden contents

 

Posted

NB: Add some error checking after each call to a _Word* function. Examples can be found in the example scripts provided in the help file for each function.

My UDFs and Tutorials:

  Reveal hidden contents

 

Posted

Should then be:

$oDoc.VBProject.VBComponents.Import("C:\temp\Modul1.bas")

My UDFs and Tutorials:

  Reveal hidden contents

 

Posted

:)

My UDFs and Tutorials:

  Reveal hidden contents

 

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...