在 Mac 版 Excel 的 Visual Basic 編輯器中發生「變數使用不支援的 Automation 類型」錯誤

上次更新:2019 年 4 月 10 日

問題

Mac 版 Excel 在 2017 年 10 月推出新版 Visual Basic 編輯器。 使用新版 Visual Basic 編輯器時,如果從程式碼視窗頂端的下拉式功能表中選擇選項,會發生建立物件宣告的問題。

如果您按一下左側的下拉式清單,然後從清單中選擇一個項目,您應該會在右側的下拉式清單中得到所選活動的部分程式碼。 您可以從右側的下拉式清單中選取其他項目,來建立額外的程式碼以處理所選活動。

顯示物件選取下拉式清單的 VBE 編輯器

但此時會發生無法建立程式碼的問題。

Microsoft Visual Basic 編輯器錯誤:變數使用在 Visual Basic 中不支援的 Automation 類型

狀態:因應措施

請選擇下列其中一個因應措施來解決此問題:

因應措施 #1

在執行 Windows 版 Excel 的電腦上執行類似步驟,然後將程式碼複製到 Mac 版 Excel。

因應措施 #2

移至 MSDN 並尋找您要使用之活動的語法,然後手動將程式碼輸入到 VBA 專案。 本文說明 Microsoft Excel「活頁簿」活動 - 活頁簿活動 (機器翻譯)。

因應措施 #3

從以下範例中複製適當的活動程式碼,並貼到 VBA 專案。 請務必針對每個活動複製 "Private Sub..." 到 "End Sub" (含) 之間的程式碼。

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

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

[專家] 圖示 (大腦、齒輪)

向專家提問

與專家交流、討論 Excel 的最新資訊、更新內容和最佳做法,並閱讀我們的部落格。

Excel 技術社群

社群圖示

在社群中取得說明

向支援專員、最有價值專家、工程人員和其他 Excel 使用者提問,並取得相關的解決方案。

Answers 上的 Excel 論壇

功能要求圖示 (燈泡、想法)

建議新功能

我們很樂意讀取您的建議和意見反應! 分享您的想法。 我們隨時洗耳恭聽。

Excel UserVoice

另請參閱

Mac 版 Excel 近期問題的修正或因應措施

增進您的 Office 技巧
探索訓練
優先取得新功能
加入 Office 測試人員

這項資訊有幫助嗎?

感謝您的意見反應!

感謝您的意見反應! 我們將協助您與其中一位 Office 支援專員連絡以深入了解您的意見。

×