none
Issue with batch file running macro in Word 2007 RRS feed

  • Question

  • Hi,
    I am trying to create a batch (.bat) file in XP that will open Word and run a specific macro using the /m[macro] switch. The macro in Word does some stuff, saves the file, and closes Word, then the batch file opens the next document, runs the macro and so on until all files in a specific dir have run.

    This is what I have got so far:
    for %%x in (*.doc) do start /wait "winword.exe" "%%x" /mMACRO1

    When placed in the same dir as all the Word files I wish to edit, it will open the first file but MACRO1 will not run. If I close the window the next Word doc will open but again, the macro does not run.

    I suspect it is something fairly simple I am missing.

    Running the below from the Run window works flawlessly:
    winword.exe "c:\path\file.docx" /mMACRO1

    Any idea what I'm missing?
    Friday, June 22, 2012 6:39 PM

Answers

  • Hard to say without seeing some code.

    It MAY be better to run all the files IN the same macro using the Dir() function.  This works very well within Word, and would permit using one instance of Word, rather than closing Word each time.  That is very inefficient.


    Word MVP

    Sunday, June 24, 2012 7:23 AM