I have written a macro (assigned to a button) in Word in Windows, and I want to use it in Word in Mac, however, the button is not working in Mac anymore, and I have to run the macro from the Visual Basic editor. Any hints?
Private Sub CommandButton_Click()
Selection.Tables(1).Columns(1).Select
With Selection.Find
.Style = "Style2"
iCount = 0
While .Execute
iCount = iCount + 1
Wend
MsgBox (iCount)
End With
End Sub
Unfortunately, you cannot link a macro to a button in Word for Mac. The button object only exists in UserForms- not directly in the Word Document. (Oddly enough, it does exist in Excel.) This has been a major frustration for me as I want to allow the users to kick off a script easily without visiting the "macros" area. You can access macros from from the Menu item: Tools -> Macro -> Macros, or the View ribbon in 2016.
Note: to make that available to the Macros area, you have to make it Public.
You can link the macro to a key command, run it from the Macros menu, or have it run on Document_New() or Document_Open().
Here's Microsoft's official way to run a macro in Mac Word (2016). https://support.office.com/en-us/article/Run-a-macro-in-Word-2016-for-Mac-e1407255-84f6-49a0-bb54-56e04bfdec23
Hope this helps.
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.