How to suppress compile errors generated from ActiveX code being present on MAC

MoshiM

Active Member
Joined
Jan 31, 2018
Messages
349
Office Version
2016
Platform
Windows
I have a workbook with code referencing activex objects that isn't supposed to be ran on if the user is on Mac, however after the user gets out of the initial read only mode upon receiving the document, ActiveX objects are deleted. Trying to run certain macros will then result in compile errors not run time errors. Is there a way to suppress these errors ?

Code:
With Application


    If .OperatingSystem Like "*Mac*" Then
    
        Navigation.Show
        
    Else
    
        .Run "'" & ThisWorkbook.Name & "'!Update_List"
        
         HB[COLOR=#ff0000].Sheet_Selection.Text[/COLOR] = "Select Sheet"


        'HB is a worksheet,  Sheet_selection is an activex combobox


    End If

end with
 

Some videos you may like

Excel Facts

Get help while writing formula
Click the italics "fx" icon to the left of the formula bar to open the Functions Arguments dialog. Help is displayed for each argument.

Jon Peltier

MrExcel MVP
Joined
May 14, 2003
Messages
4,851
Office Version
365
Platform
Windows, MacOS
Conditional compilation is indicated by the leading #:

Code:
#If Mac Then
  ' do nothing
[URL=https://www.mrexcel.com/forum/usertag.php?do=list&action=hash&hash=Else]#Else[/URL] 
  ' ActiveX code that's going to crash goes here
[URL=https://www.mrexcel.com/forum/usertag.php?do=list&action=hash&hash=End]#End[/URL]  If
Of course, the best approach is to eliminate the ActiveX objects in favor of less sexy but more robust Form controls.
 

Watch MrExcel Video

Forum statistics

Threads
1,099,549
Messages
5,469,378
Members
406,647
Latest member
ssinovec

This Week's Hot Topics

Top