M
maperalia
I wonder if you can help me to make this windows message works properly.
The macro I have opens "lst" and "dat" files by selecting a cell (see
below). However, I wanted to place a windows message warning that I did not
select a cell with the filename.
The problem is that my windows message appears regardless I pick the correct
cell with the filename and then open the file.
Could you please tell me what I am doing wrong?
Thanks in advance.
Maperalia
'**************************
Sub Open_file_dat_or_lst()
Application.ScreenUpdating = False
WO = Worksheets("DEFAULTS").Range("C3")
directory = "S:\GEOTEST\shears\" & WO & "\"
filetext = Selection.Value
If Dir(directory & filetext & ".lst") <> "" Then
Else
MsgBox "SELECT FILENAME CELL WITH DESCRIPTION"
End If
Workbooks.Open directory & filetext
Application.ScreenUpdating = False
If Right(filetext, 4) = ".dat" Then
Open_dat_File
ElseIf Right(filetext, 4) = ".lst" Then
Open_lst_File
Else
MsgBox (" .... unknown file type...")
End If
Application.ScreenUpdating = True
End Sub
'**************************
The macro I have opens "lst" and "dat" files by selecting a cell (see
below). However, I wanted to place a windows message warning that I did not
select a cell with the filename.
The problem is that my windows message appears regardless I pick the correct
cell with the filename and then open the file.
Could you please tell me what I am doing wrong?
Thanks in advance.
Maperalia
'**************************
Sub Open_file_dat_or_lst()
Application.ScreenUpdating = False
WO = Worksheets("DEFAULTS").Range("C3")
directory = "S:\GEOTEST\shears\" & WO & "\"
filetext = Selection.Value
If Dir(directory & filetext & ".lst") <> "" Then
Else
MsgBox "SELECT FILENAME CELL WITH DESCRIPTION"
End If
Workbooks.Open directory & filetext
Application.ScreenUpdating = False
If Right(filetext, 4) = ".dat" Then
Open_dat_File
ElseIf Right(filetext, 4) = ".lst" Then
Open_lst_File
Else
MsgBox (" .... unknown file type...")
End If
Application.ScreenUpdating = True
End Sub
'**************************