Office
Sign in

"Variable uses an Automation type not supported" error in Visual Basic editor in Excel for Mac

Last Updated: November 10, 2017

ISSUE

In Excel for Mac, a new Visual Basic Editor was introduced in October 2017. With this new VB editor, there's an issue with creating object declarations by choosing from the drop-down menu at the top of the code window.

If you click the drop-down on the left and choose an item from the list, you should get some code for the selected event in the drop-down list on the right. You can make additional selections from the drop-down list on the right to create additional code to handle the chosen event.

VBE Editor showing object selection dropdown list

Instead, an error occurs that the code is not created.

Microsoft Visual Basic Error: Variable uses and automation type not supported in Visual Basic.

STATUS: WORKAROUND

Choose one of these workarounds for this issue:

WORKAROUND #1

You can perform the similar step on a computer running Excel for Windows and then copy the code to Excel for Mac.

WORKAROUND #2

You can go to MSDN and find the syntax for the event you wish to use and type the code manually into your VBA project. This article describes the Microsoft Excel "workbook" events - Workbook Events.

WORKAROUND #3

Copy the appropriate event code from the samples below and paste it to your VBA project. For each event, be sure to copy from "Private Sub..." to "End Sub", inclusive.

    
    

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

Icon Experts (brain, gears)

Ask the experts

Connect with experts, discuss the latest Excel news, updates, and best practices, and read our blog.

Excel Tech Community

Icon Community

Get help in the community

Ask a question and find solutions from Support Agents, MVPs, Engineers, and other Excel users.

Excel Forum on Answers

Icon feature request (light bulb, idea)

Suggest a new feature

We love reading your suggestions and feedback! Share your thoughts. We're listening.

Excel UserVoice

See Also

Fixes or workarounds for recent issues in Excel for Mac

Expand your Office skills
Explore training
Get new features first
Join Office Insiders

Was this information helpful?

Thank you for your feedback!

Thank you for your feedback! It sounds like it might be helpful to connect you to one of our Office support agents.

×