locked
Triggering the macros when creating word document RRS feed

  • Question

  • Hi,

    Using Microsoft Flow I create word documents into a SharePoint document library based off a word template I created. The template contains 3 macros: 1. to format text, 2. to insert an online pic, 3. to send an email of the doc.

    The problem I have, is I need a way to automatically trigger the macros to run when the document is created.

    Currently I have set the macros to the Open() function which runs when the document is opened, but this isn't good enough. And I have tried the New() function, but no luck.

    So my question is, am I able to achieve this using PowerShell?

    *The word documents are stored inside SharePoint Online document library.

    Thank you.

    Wednesday, February 28, 2018 10:59 AM

All replies

  • You need to post Word issues in the Word developers forum.

    There is no way to cause a macro to run when a document is created. Only the document OnOpen event or the Run() method can run macros from PowerShell.


    \_(ツ)_/

    Wednesday, February 28, 2018 11:18 AM
  • You need to post Word issues in the Word developers forum.

    There is no way to cause a macro to run when a document is created. Only the document OnOpen event or the Run() method can run macros from PowerShell.


    \_(ツ)_/

    Hi,

    Thanks for the reply.

    As for running the macros, will I be able to use PowerShell to automatically open a word document inside a SharePoint document library when a new file is added? Thus running the macros.

    From what I understand, you're saying no, but I just want to clarify.

    Thanks.

    • Edited by t3ch21 Wednesday, February 28, 2018 12:00 PM
    Wednesday, February 28, 2018 11:59 AM
  • No.  You will have to download the file first.  What do you mean by "Automatically"?

    \_(ツ)_/

    Wednesday, February 28, 2018 2:46 PM
  • No.  You will have to download the file first.  What do you mean by "Automatically"?

    \_(ツ)_/

    Well I would want to have some sort of trigger e.g. when a file gets created in the document library. It would run a script automatically, that would download, open and let the macros run.

    So I don't have to manually execute the script.


    • Edited by t3ch21 Wednesday, February 28, 2018 2:57 PM
    Wednesday, February 28, 2018 2:55 PM
  • Don't see any way to do that.  The documents only exist in SharePoint and cannot be directly executed.   Perhaps a workflow in SharePoint can manipulate the document but it will not be able to download it or execute PowerShell.


    \_(ツ)_/

    Wednesday, February 28, 2018 3:03 PM