how to run a macro in word

  • Thread starter Thread starter jakie
  • Start date Start date
J

jakie

please help!
i have a macro that i have created in excel. I will like
to create a command botton in word to call that macro.
basically, the final product is viewed in word. I was
able to use the command botton but i am not able to have
it point to the macro in excel.

I have used
Private Sub CommandButton1_Click()
Call Macro1
End Sub

but this is telling me to search for help. even when i
copy the code from excel to word.
that u
 
Hello jakie,


Code:
--------------------

Private Sub CommandButton1_Click()
Dim oXl As Object
Set oXl = CreateObject("Excel.Application")
'Or if XL wkb is already opened use GetObject instead.
'And do not have to be visibled and to be opened.
With oXl
.Visible = True
.workbooks.Open ("C:\Book1.xls")
.Application.Run "Macro1"
End With
Set oXl = Nothing
End Sub

--------------------
 
Thanks jakie. I am not able to us the codes. One thing i
did not make clear was that although this is word docu.
it is actual the web word. So what i will do is open the
document in word then use the control box to add the
command click. I then edit and paste your code. then save
again as web. After this process it would not work. could
you please help.
 
Back
Top