Herkese Merhaba, aşağıdaki kodu formu arştırırken gördüm, kod hardiskin D bölümünde içine 123456 yazılmış bir txt dosyası varsa excel dosyasını aç yoksa açma şeklinde biçimlendirilmiş.acaba ben bunu belirlediğim bilgisayrlarda nasıl yapabilirim kriter şu şekilde olmalı 20 tane pc var herkesin D bölümünde ismi var D:\eftel\MyDocument D:\ali\Mydocument.... .... ... gibi .
"D:\eftel\MyDocument\ac.txt" or " D:\ali\MyDocument \ac.txt" diye mi değiştirmem gerekiyor ?
Kod:
Const strTxtFile As String = "D:\eftel\My Documents\ac.txt"
Const MyCheckVal As Long = 123456
'
Sub Auto_Open()
Dim InputData As Variant
Dim FileNum As Long
Dim x As Integer
FileNum = FreeFile
If Dir(strTxtFile) <> Empty Then
Open strTxtFile For Input As FileNum
x = x + 1
Do While Not EOF(FileNum)
Line Input #FileNum, InputData
If Left(InputData, 6) <> MyCheckVal Then GoTo NoGo:
If x = 1 Then Exit Sub
Loop
Close FileNum
ThisWorkbook.IsAddin = False
Else
NoGo:
ThisWorkbook.IsAddin = True
MsgBox "BU DOSYAYI AÇMAYA YETKİLİ DEĞİLSİNİZ", vbCritical, "UYARI"
ThisWorkbook.Close SaveChanges:=False
End If
End Sub
"D:\eftel\MyDocument\ac.txt" or " D:\ali\MyDocument \ac.txt" diye mi değiştirmem gerekiyor ?
Son düzenleme:
