View Single Post
  #2   Report Post  
Posted to microsoft.public.excel.programming
Tom Ogilvy Tom Ogilvy is offline
external usenet poster
 
Posts: 27,285
Default Open a specific file

http://support.microsoft.com/default...b;en-us;157320
XL97: Macro Cannot Open a File That Has No Extension


http://support.microsoft.com/default...b;en-us;213785
XL2000: Macro Cannot Open a File That Has No Extension

Looks like it hasn't been fixed.

--
Regards,
Tom Ogilvy

"anomymousA" wrote in message
...
Hi,

First of all, I aplogize for the bad quality of my english but I already
asked this question on the French Newsgroup and got no answers.

I encounter a difficulty in Excel to open a given file.

Let's be more specific. In a given repertory, I have 2 files which have

the
same name but one is without extension and the other with a extension.xls.
The 1st one is text but is imported from another application (not

OFFICE).
By the following procedure, I let the user chose the file he wishes. The
difficulty is that when he clicks on the file without extension, Excel is
obstinated to open the Excel file by defect.
Carry out the test by creating a textual file toto.txt and remove its
extension in the Explorer then create a file toto.xls in the same

repertory.
You use the following procedure and you will see that Excel always opens
toto.xls even if you have chosed the one without extension, or then it is
that there is another thing and it is precisely what I'm looking for. I

use
Excel 2000 and win NT4.

Set fso = CreateObject("Scripting.FileSystemObject")

ctrl1 = False

While ctrl1 = False
Set filetopen = Nothing
filetoopen = Application.GetOpenFilename
If filetoopen < False Then
If (fso.GetFile(filetoopen).Type < "File" And
fso.GetFile(filetoopen).Type < "Document texte") Then
MsgBox "You didn't choose a Text file or a file with non

extension"
& Chr(13) & "Abort or retry"
Else
ctrl1 = True
End If
Else
Set fso = Nothing
With Application
.DisplayAlerts = True
.ScreenUpdating = True
.AskToUpdateLinks = True
.EnableCancelKey = xlInterrupt
End With
Exit Sub
End If
Wend

Workbooks.OpenText Filename:=filetoopen, Origin:=xlWindows, Tab:=True,
Other:=True, OtherChar:="!"

In addition, if the file don't have any extension, Windows, at the time of
the assignment of filetoopen , sticks a point at its end .
Sure I could ask the users to carry an extension to the files which they
extract from the other application, which would solve the problem but I

want
to understand if it is possible to make Excel open the file which I wish

and
not another one.

Thanks

A+