首先需要说明的是:它不支持,就算你把代码贴上去,它也不会自动执行。除非你想让其在 Windows 中能够执行,否则凡事它不支持的都不要再勉强了。
2017 年 10 月,Excel for Mac 中引入了新的 Visual Basic 编辑器。 引入此新 VB 编辑器以来,通过从代码窗口顶部的下拉菜单中进行选择的方式来创建对象声明存在问题。
如果你单击左侧的下拉菜单并从列表中选择一项,应在右侧的下拉列表中获得所选事件的一些代码。 你可以从右侧的下拉列表中进行其他选择,以创建其他代码来处理所选事件。
92d8bfb0-dd1b-45ee-b068-621bf3aa6c94.png a242ed6e-f56a-4abb-ad73-bcf2944a87c0.png
解决方法
请选择以下临时解决方法之一解决此问题:
临时解决方法 1
你可以在运行 Excel for Windows 的计算机上执行相似的步骤,然后将代码复制到 Excel for Mac。
临时解决方法 2
你可以转到 MSDN,找到想要使用的事件的语法,并手动将代码键入 VBA 项目。 本文介绍 Microsoft Excel“工作簿”事件 - 工作簿事件。
临时解决方法 3
复制以下示例中的相应事件代码,并将其粘贴到 VBA 项目。 每个事件都必须从“Private Sub...”部分复制到“End Sub”部分(包含这两句)。
- ThisWorkbook
Private Sub Workbook_Activate()
End Sub
Private Sub Workbook_AddinInstall()
End Sub
Private Sub Workbook_AddinUninstall()
End Sub
Private Sub Workbook_AfterRemoteChange()
End Sub
Private Sub Workbook_AfterSave(ByVal Success As Boolean)
End Sub
Private Sub Workbook_BeforeClose(Cancel As Boolean)
End Sub
Private Sub Workbook_BeforePrint(Cancel As Boolean)
End Sub
Private Sub Workbook_BeforeRemoteChange()
End Sub
Private Sub Workbook_BeforeSave(ByVal SaveAsUI As Boolean, Cancel As Boolean)
End Sub
Private Sub Workbook_Deactivate()
End Sub
Private Sub Workbook_NewChart(ByVal Ch As Chart)
End Sub
Private Sub Workbook_NewSheet(ByVal Sh As Object)
End Sub
Private Sub Workbook_Open()
End Sub
Private Sub Workbook_PivotTableCloseConnection(ByVal Target As PivotTable)
End Sub
Private Sub Workbook_PivotTableOpenConnection(ByVal Target As PivotTable)
End Sub
Private Sub Workbook_RowsetComplete(ByVal Description As String, ByVal Sheet As String, ByVal Success As Boolean)
End Sub
Private Sub Workbook_SheetActivate(ByVal Sh As Object)
End Sub
Private Sub Workbook_SheetBeforeDelete(ByVal Sh As Object)
End Sub
Private Sub Workbook_SheetBeforeDoubleClick(ByVal Sh As Object, ByVal Target As Range, Cancel As Boolean)
End Sub
Private Sub Workbook_SheetBeforeRightClick(ByVal Sh As Object, ByVal Target As Range, Cancel As Boolean)
End Sub
Private Sub Workbook_SheetCalculate(ByVal Sh As Object)
End Sub
Private Sub Workbook_SheetChange(ByVal Sh As Object, ByVal Target As Range)
End Sub
Private Sub Workbook_SheetDeactivate(ByVal Sh As Object)
End Sub
Private Sub Workbook_SheetFollowHyperlink(ByVal Sh As Object, ByVal Target As Hyperlink)
End Sub
Private Sub Workbook_SheetPivotTableAfterValueChange(ByVal Sh As Object, ByVal TargetPivotTable As PivotTable, ByVal TargetRange As Range)
End Sub
Private Sub Workbook_SheetPivotTableBeforeAllocateChanges(ByVal Sh As Object, ByVal TargetPivotTable As PivotTable, ByVal ValueChangeStart As Long, ByVal ValueChangeEnd As Long, Cancel As Boolean)
End Sub
Private Sub Workbook_SheetPivotTableBeforeCommitChanges(ByVal Sh As Object, ByVal TargetPivotTable As PivotTable, ByVal ValueChangeStart As Long, ByVal ValueChangeEnd As Long, Cancel As Boolean)
End Sub
Private Sub Workbook_SheetPivotTableBeforeDiscardChanges(ByVal Sh As Object, ByVal TargetPivotTable As PivotTable, ByVal ValueChangeStart As Long, ByVal ValueChangeEnd As Long)
End Sub
Private Sub Workbook_SheetPivotTableChangeSync(ByVal Sh As Object, ByVal Target As PivotTable)
End Sub
Private Sub Workbook_SheetPivotTableUpdate(ByVal Sh As Object, ByVal Target As PivotTable)
End Sub
Private Sub Workbook_SheetSelectionChange(ByVal Sh As Object, ByVal Target As Range)
End Sub
Private Sub Workbook_SheetTableUpdate(ByVal Sh As Object, ByVal Target As TableObject)
End Sub
Private Sub Workbook_Sync(ByVal SyncEventType As Office.MsoSyncEventType)
End Sub
Private Sub Workbook_WindowActivate(ByVal Wn As Window)
End Sub
Private Sub Workbook_WindowDeactivate(ByVal Wn As Window)
End Sub
Private Sub Workbook_WindowResize(ByVal Wn As Window)
End Sub
- Sheets
Private Sub Worksheet_Activate()
End Sub
Private Sub Worksheet_BeforeDelete()
End Sub
Private Sub Worksheet_BeforeDoubleClick(ByVal Target As Range, Cancel As Boolean)
End Sub
Private Sub Worksheet_BeforeRightClick(ByVal Target As Range, Cancel As Boolean)
End Sub
Private Sub Worksheet_Calculate()
End Sub
Private Sub Worksheet_Change(ByVal Target As Range)
End Sub
Private Sub Worksheet_Deactivate()
End Sub
Private Sub Worksheet_FollowHyperlink(ByVal Target As Hyperlink)
End Sub
Private Sub Worksheet_LensGalleryRenderComplete()
End Sub
Private Sub Worksheet_PivotTableAfterValueChange(ByVal TargetPivotTable As PivotTable, ByVal TargetRange As Range)
End Sub
Private Sub Worksheet_PivotTableBeforeAllocateChanges(ByVal TargetPivotTable As PivotTable, ByVal ValueChangeStart As Long, ByVal ValueChangeEnd As Long, Cancel As Boolean)
End Sub
Private Sub Worksheet_PivotTableBeforeCommitChanges(ByVal TargetPivotTable As PivotTable, ByVal ValueChangeStart As Long, ByVal ValueChangeEnd As Long, Cancel As Boolean)
End Sub
Private Sub Worksheet_PivotTableBeforeDiscardChanges(ByVal TargetPivotTable As PivotTable, ByVal ValueChangeStart As Long, ByVal ValueChangeEnd As Long)
End Sub
Private Sub Worksheet_PivotTableChangeSync(ByVal Target As PivotTable)
End Sub
Private Sub Worksheet_PivotTableUpdate(ByVal Target As PivotTable)
End Sub
Private Sub Worksheet_SelectionChange(ByVal Target As Range)
End Sub
Private Sub Worksheet_TableUpdate(ByVal Target As TableObject)
End Sub
网友评论