Ok ... my mistake.
In your first Word .docm ... in the "ThisDocument" paste "
Option Explicit Private Sub CommandButton1_Click() RunMacroInSecondDocument End Sub
Then in a regular module paste :
[/CODE]Sub RunMacroInSecondDocument() Dim wdApp As Object Dim wdDoc As Object ' Open the second Word document Set wdApp = CreateObject("Word.Application") Set wdDoc = wdApp.Documents.Open("C:\Users\logit\OneDrive\Desktop\Doc2.docm") ' Run the macro in the second Word document wdApp.Run "hellow" ' Close the second Word document wdDoc.Close False wdApp.Quit Set wdDoc = Nothing Set wdApp = Nothing End Sub
Note ... for testing purposes my second Word document is named Doc2.docm . You'll adjust the name in the macro for your own purposes.




Reply With Quote