Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 1
Default Open a specific file

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+

  #2   Report Post  
Posted to microsoft.public.excel.programming
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+



  #3   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 32
Default Open a specific file

Great Thanks to you, Tom

reading you once more, I can confirm you're one of the bests.

So long


Tom Ogilvy a écrit :
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.

Reply
Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules

Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On


Similar Threads
Thread Thread Starter Forum Replies Last Post
Is there a way to open an excel file to a specific worksheet? Nicholas Excel Discussion (Misc queries) 1 December 5th 06 10:29 PM
Open file to specific tab [email protected] Excel Discussion (Misc queries) 5 June 16th 06 03:55 AM
Macro to open specific File tamato43 Excel Discussion (Misc queries) 4 May 18th 05 09:42 PM
How to use macro to open an specific file Rafael Chang[_2_] Excel Programming 1 October 8th 04 07:47 PM
Open Specific File DB100[_3_] Excel Programming 2 May 10th 04 09:17 AM


All times are GMT +1. The time now is 10:26 AM.

Powered by vBulletin® Copyright ©2000 - 2025, Jelsoft Enterprises Ltd.
Copyright ©2004-2025 ExcelBanter.
The comments are property of their posters.
 

About Us

"It's about Microsoft Excel"