+ Reply to Thread
Results 1 to 2 of 2

VBA Not Working on MacOS

Hybrid View

recalling VBA Not Working on MacOS 11-09-2020, 05:32 PM
hrlngrv Re: VBA Not Working on MacOS 11-09-2020, 05:50 PM
  1. #1
    Registered User
    Join Date
    11-09-2020
    Location
    Chile
    MS-Off Ver
    MacOS
    Posts
    1

    VBA Not Working on MacOS

    Hello everyone, I need your help with a VBA code that works on Windows but when it's used on MacOS throw the ActiveX Error 429.

    Sub book_open()
    'This macro will show the sheets when confirm if the hard drive number is allowed to use the file
    Application.ScreenUpdating = False
    Dim ws As Worksheet
    For Each ws In ThisWorkbook.Worksheets
        ws.Visible = xlSheetVisible
    Next ws
    Set ws = Nothing
    'Sheets("Inicio").Visible = xlVeryHidden
    Hoja1.Select
    End Sub
    
    ---
    
    Sub book_close()
    'This macro must be run before to close the book and make his call from the procedure...
    '... "Private Sub Workbook_BeforeClose" on "Workbook" from the code's object ThisWorkbook
    Application.ScreenUpdating = False
    Dim hj As Worksheet
    Sheets("Inicio").Visible = xlSheetVisible
    For Each hj In ThisWorkbook.Worksheets
        If hj.Name <> "Inicio" Then
            hj.Visible = xlVeryHidden
        End If
    Next hj
    Set hj = Nothing
    ThisWorkbook.Save
    End Sub
    
    ---
    
    Sub Database()
    'This macro is that must be run when the book it's opened
    'verify that the serial number of the hard drive it's the same
    'if is false, send you the message and it can't run the book and closes it
    'if is true, then run the macro "book_open"
    Application.ScreenUpdating = False
    Dim Serie As String
    Dim FSO As Object
    Dim DiscoDuro As Object
    Set FSO = CreateObject("Scripting.FileSystemObject")
    Set DiscoDuro = FSO.GetDrive("c:")
    Serie = DiscoDuro.SerialNumber
    If Serie <> "-xxxxxxxxx" Then
        MsgBox "Warning, you're not authorized."
        ThisWorkbook.Close SaveChanges:=False
    ElseIf Serie = "-xxxxxxxxx" Then
        Call book_open 'here runs the macro that show you the sheets, when verify the serial number of the hard drive
    End If
    Set DiscoDuro = Nothing
    Set FSO = Nothing
    End Sub
    The bold text is the code that don't allow me to use it on MacOS. It would be great if you could rewrite my code to be able to use this VBA on MacOS because I'm no expert and this is important for my work.

    I'll wait patiently for your answers. Thank you.

  2. #2
    Forum Expert
    Join Date
    07-06-2004
    Location
    Northern California
    MS-Off Ver
    2K, 2003, 2010, O365
    Posts
    1,490

    Re: VBA Not Working on MacOS

    Scripting.* is provided by SCRRUN.DLL, the Windows Script Host. That's Windows-only. No Mac equivalent AFAIK.

    Rule of thumb: EVERYTHING involving CreateObject or GetObject is Windows-only. If you want similar functionality on Macs, YOU have to recreate it yourself.

    Sorry to be blunt, but you need to find alternatives.

    Tangent: Macs lack C: drives, so Set DiscoDuro = FSO.GetDrive("c:") would also cause problems on Macs.

    If you're trying to get serial numbers of physical drives or partitions, Macs have terminals and complete POSIX tool sets. You should be able to get physical drives' serial numbers using

    hdparm -I /dev/[hs]d? | awk '/^\/dev\// { d = $1 }; /Serial Number:/ {print d, $3 }'

    CORRECTION: the command above is only for Linux. For Macs, you'd need to use /usr/sbin/diskutil info. I have no experience with it, but it seems to be the command and argument you'd need to use.
    Last edited by hrlngrv; 11-09-2020 at 06:04 PM. Reason: correction

+ Reply to Thread

Thread Information

Users Browsing this Thread

There are currently 1 users browsing this thread. (0 members and 1 guests)

Similar Threads

  1. Auto Indent - Setting on MacOS Where
    By lord anubis in forum Excel General
    Replies: 6
    Last Post: 11-02-2019, 09:12 AM
  2. Excel Addin on MacOS
    By lollapalooza in forum Excel Programming / VBA / Macros
    Replies: 3
    Last Post: 06-26-2019, 12:42 PM
  3. macOS 10.14 Mojave will be 64 Bit
    By mitchvail in forum For Other Platforms(Mac, Google Docs, Mobile OS etc)
    Replies: 1
    Last Post: 09-06-2018, 02:16 AM
  4. Is there a MACOS version of WinHttp.WinHttpRequest.5.1
    By ThePlanner in forum Office 365
    Replies: 2
    Last Post: 02-03-2018, 08:05 PM
  5. [SOLVED] My macos won't run on the next row (it only works on the first row)
    By hcyeap in forum Excel Programming / VBA / Macros
    Replies: 7
    Last Post: 12-02-2013, 03:25 PM
  6. Macos If then Statement help
    By bapella in forum Excel Programming / VBA / Macros
    Replies: 1
    Last Post: 06-12-2012, 02:42 PM
  7. Diabling Target Workboon Macos (if necessary)
    By ExcelMonkey in forum Excel Programming / VBA / Macros
    Replies: 1
    Last Post: 02-01-2006, 09:15 AM

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts

Search Engine Friendly URLs by vBSEO 3.6.0 RC 1