Home > Software engineering >  Range of vba auto_open method when applied to object _global failure
Range of vba auto_open method when applied to object _global failure

Time:04-01

After a few days ago a written list of vba, the requirement is open a excel worksheets will automatically perform, I write the code as follows:
 Private Sub Auto_Open () 
Dim Obj As Object, sn As String
For Each Obj In GetObject (" WinMgmts: "). InstancesOf (" Win32_BaseBoard ")
Sn=Obj. SerialNumber
Next

If the Range (" A24 ")="NC program name" Then
If sn="K716333294" Then
Call the Work
The Else
MsgBox "equipment authentication failed!"
End the If
End the If
End Sub

` ` `
I put it in add-in, such errors: method range ACTS on the object _global failed
Points to the
 If the Range (" A24 ")="NC program name" Then 


I suspect the macro when run automatically, excel spreadsheet is not finished loading,
Can you tell me bosses how to solve
  •  Tags:  
  • VBA
  • Related