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.
Bookmarks