ExcelBanter

ExcelBanter (https://www.excelbanter.com/)
-   Excel Programming (https://www.excelbanter.com/excel-programming/)
-   -   how to run a macro in word (https://www.excelbanter.com/excel-programming/287040-how-run-macro-word.html)

jakie

how to run a macro in word
 
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

Colo[_76_]

how to run a macro in word
 
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

--------------------



---
Message posted from http://www.ExcelForum.com/


jakie[_2_]

Jakie? how to run a macro in word
 
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.
-----Original Message-----
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
.



All times are GMT +1. The time now is 01:05 AM.

Powered by vBulletin® Copyright ©2000 - 2025, Jelsoft Enterprises Ltd.
ExcelBanter.com