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

MoshiM

Active Member
Joined
Jan 31, 2018
Messages
290
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
 

Jon Peltier

MrExcel MVP
Joined
May 14, 2003
Messages
4,730
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.
 

Forum statistics

Threads
1,082,346
Messages
5,364,823
Members
400,814
Latest member
gangstar67

Some videos you may like

This Week's Hot Topics

  • populate from drop list with multiple tables
    Hi All, i have a drop list that displays data, what i want is when i select one of those from the list to populate text from different tables on...
  • Find list of words from sheet2 in sheet1 before a comma and extract text vba
    Hi Friends, Trying to find the solution on my task. But did not find suitable one to the need. Here is my query and sample file with details...
  • Dynamic Formula entry - VBA code sought
    Hello, really hope one of you experts can help with this - i've spent hours on this and getting no-where. .I have a set of data (more rows than...
  • Listbox Header
    Have a named range called "AccidentsHeader" Within my code I have: [CODE]Private Sub CommandButton1_Click() ListBox1.RowSource =...
  • Complex Heat Map using conditional formatting
    Good day excel world. I have a concern. Below link have a list of countries that carries each country unique data. [URL...
  • Conditional formatting
    Hi good morning, hope you can help me please, I have cells P4:P54 and if this cell is equal to 1 then i want row O to say "Fully Utilised" and to...
Top