perbaikan script

  1. 4 bulan yang lalu

    Dear master....
    mohon dapat dibantu perbaikan script dibawah ini, sebetulnya script terlampir sudah berfungsi sesuai yang diinginkan, akan tetapi dikala file codein.txt filenya saya hilangkan, keluarnya tidak normal dan seperti hang.....

    terima kasih sebelumnya

    scriptnya ;

    Private Sub Workbook_Open()
    Dim sHostName As String 'get computer name
    Dim passw As String
    Dim myFile As String
    Dim text As String
    Dim textline As String
    Dim retvalue As String

    On Error Resume Next
    With Application
    .VBE.MainWindow.Visible = False
    .Visible = False
    End With
    Application.ScreenUpdating = False
    Application.WindowState = xlMaximized
    ActiveWorkbook.RunAutoMacros xlAutoOpen
    sHostName = Right(Environ$("computername"), 5)

    tulis (1)

    retvalue = Application.ActiveWorkbook.Path
    myFile = retvalue & "\codein.txt"
    If myFile <> "" Then
    On Error Resume Next
    Open myFile For Input As #1
    Do Until EOF(1)
    Line Input #1, textline
    text = text & textline
    Loop
    Close #1
    passw = text
    'MsgBox passw
    Else
    End If

    If "MyserialUPHBD123" = "Myserial" & sHostName Or DecryptWithALP(passw) = sHostName Then
    On Error Resume Next
    With Application
    .VBE.MainWindow.Visible = True
    .Visible = True
    End With
    Else
    With Application
    .Visible = False
    .VBE.MainWindow.Visible = False
    .ThisWorkbook.Save
    .DisplayAlerts = False
    .Quit
    End With
    Unload Me
    End If
    End Sub
    Sub tulis(a As Long)
    Dim strFileAndPath As String
    Dim objFSO As Object
    Dim objFile As Object
    sHostName = Right(Environ$("computername"), 5)
    retvalue = ActiveWorkbook.FullName
    strFileAndPath = retvalue
    Set finalFile = ActiveWorkbook
    retvalue = Application.ActiveWorkbook.Path
    'MsgBox retvalue
    Set objFSO = CreateObject("Scripting.FileSystemObject")
    Set objFile = objFSO.CreateTextFile(retvalue & "\code.txt")
    objFile.WriteLine sHostName
    objFile.Close
    Set objFSO = Nothing
    Set objFile = Nothing
    End Sub

 

atau Mendaftar untuk ikut berdiskusi!