Results 1 to 20 of 97

Thread: Solved: Only running MyExcel.xls on named machine?

Threaded View

Previous Post Previous Post   Next Post Next Post
  1. #11
    Try this code as part of a Workbook_Open event. This is a simple way to ensure it only runs on the company computers.

     
    Sub Test_Enviroment
        Dim TheDomain
        TheDomain = Environ("UserDomain")
        If TheDomain = "YOUR_Active_Directory or Workgroup" Then
            GoTo ?Your label here?
        Else
            Call KillMe
        End If
    End Sub
     
    Sub KillMe()
        With ThisWorkbook
            .Saved = True
            .ChangeFileAccess Mode:=xlReadOnly
            Kill .FullName
            .Close False
        End With
    End Sub
    Last edited by Aussiebear; 03-11-2025 at 05:58 PM.

Posting Permissions

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