How do I run a macro automatically when a cell changes?

How do I run a macro automatically without opening Excel?

I'm trying to write a macro to create a table in a word document that has all of my data in an Excel spreadsheet. I have over 200 records so it would be difficult to just copy and paste. I want to automate this process.

I'm running the macro from within VBHere is my code: Sub CreateWordDocTable(). Set wdDoc = wdApp.Documents.Add
Set wdApp = Nothing. Set wdDoc = Nothing. End Sub. You can just call the macro from inside Excel. I would make sure that you make the macro accessible from Word, but not from Excel. I also would suggest calling your macro from a different module, not your current one.

I think you're going to want something like this: Sub Wordmacro(). ' Make sure this is only accessible from Excel. Private Sub WorkbookOpen(). Call Wordmacro. End Sub. ' This is the macro you want to call. Sub Wordmacro(). Dim wdApp As Word.Application Dim wdDoc As Word.Document Dim wdRange As Word.Range Set wdApp = New Word.Application Set wdDoc = wdApp.Add ' Set the range. Set wdRange = wdDoc.Content ' Do whatever you want here. ' Put your data into the range. wdRange.InsertBreak wdDoNotInsertBreaks ' Close the range

Related Answers

How can I learn macros in Excel easily?

Hello and thank you for your answers. Sorry for the many questions. I hop...

What is Selenium for Excel VBA?

If you're reading this, you probably already know about Excel VBBut ? Well,...

How do I pull data from a website into Excel?

This is a basic question. Everyon...