-
I asked beofre, and someone gave me this code: (sorry I'm not sure who)
Code:
sfile = "C:\01.dat"
Dim FSO As Object
Set FSO = CreateObject("Scripting.FileSystemObject")
If FSO.fileexists(sfile) = True Then
user32.Visible = True
Form2.Visible = False
Else:
Form2.Visible = False
Form1.Visible = True
End If
Set FSO = Nothing
but everytime the code is processed, it always shows form1, even is the file does exsist
-
Try explicitly hiding Form1:
Code:
Dim FSO As Object
Dim sFile as String
sFile = "C:\01.dat"
Set FSO = CreateObject("Scripting.FileSystemObject")
If FSO.fileexists(sFile) = True Then
user32.Visible = True
Form2.Visible = False
Form1.Visible = False
Else
Form2.Visible = False
Form1.Visible = True
End If
Set FSO = Nothing
-
sorry, it doesn't work. Also removed the 3 lines:
else
form2.visivle = false
form1.visible = true
and then it just stays on form2
also I am 100% positive that the file exsists
-
Make sure that the file isn't System or Hidden.
-
I'm sure that its not hidden or anything
-
Try this, using a different file:
Code:
Dim sFile As String
Dim FSO As Object
sFile = "C:\autoexec.bat"
Set FSO = CreateObject("Scripting.FileSystemObject")
If FSO.FileExists(sFile) = True Then
Debug.Print "Exist"
Else
Debug.Print "Not exist"
End If
Set FSO = Nothing
I'm not sure what's up with your other file, so see if it works with any other file.
-
Put a breakpoint in the Load event for Form2 and when it is displayed, examine the call stack to see how the event was triggered. I'll make a small bet that there is something in Form1 that is referring to some visible object on Form2, and anytime you do that, the form is shown.
-
What is User32? Is it a control on one of these forms? Also, you are setting Form2.Visible = False on both sides of the If/Else statement.