Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 3
Default xlDialogImportTextFile txt file name

I am calling xlDialogImportTextFile, selecting the txt file to import, and
then manipulating the imported data.

How do I capture the name of the txt file I selected to import and still use
xlDialogImportTextFile?
  #2   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 133
Default xlDialogImportTextFile txt file name

Not sure if it's possible. The following is how I do that sort of thing - it
captures the file path which you can then feed into other routines (the If is
there to stop users picking more than one file - you may want to let them!):

Sub ReturnFile()
Dim dlg As FileDialog
Dim strPath As String

OpenAgain:
Set dlg = Application.FileDialog(msoFileDialogFilePicker)
With dlg
If .Show = -1 Then
If .SelectedItems.Count 1 Then
MsgBox "You must open only one file."
GoTo OpenAgain
End If
strPath = .SelectedItems(1)
Else
Exit Sub
End If
End With
Set dlg = Nothing
MsgBox strPath
End Sub

"FallenFigLeaf" wrote:

I am calling xlDialogImportTextFile, selecting the txt file to import, and
then manipulating the imported data.

How do I capture the name of the txt file I selected to import and still use
xlDialogImportTextFile?

  #3   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 3
Default xlDialogImportTextFile txt file name

Many thanks,
Unfortunately, this routine does not launch the txt import process, and
since the file of interest is a txt, it does not open as a "workbook" or as
anything. Your routine works great for xl files, by capturing the path, but
not for other types of files. Thanks none the less.

"Smallweed" wrote:

Not sure if it's possible. The following is how I do that sort of thing - it
captures the file path which you can then feed into other routines (the If is
there to stop users picking more than one file - you may want to let them!):

Sub ReturnFile()
Dim dlg As FileDialog
Dim strPath As String

OpenAgain:
Set dlg = Application.FileDialog(msoFileDialogFilePicker)
With dlg
If .Show = -1 Then
If .SelectedItems.Count 1 Then
MsgBox "You must open only one file."
GoTo OpenAgain
End If
strPath = .SelectedItems(1)
Else
Exit Sub
End If
End With
Set dlg = Nothing
MsgBox strPath
End Sub

"FallenFigLeaf" wrote:

I am calling xlDialogImportTextFile, selecting the txt file to import, and
then manipulating the imported data.

How do I capture the name of the txt file I selected to import and still use
xlDialogImportTextFile?

  #4   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 133
Default xlDialogImportTextFile txt file name

Try: strFile = Application.GetOpenFilename("Text Files (*.txt), *.txt")

"FallenFigLeaf" wrote:

Many thanks,
Unfortunately, this routine does not launch the txt import process, and
since the file of interest is a txt, it does not open as a "workbook" or as
anything. Your routine works great for xl files, by capturing the path, but
not for other types of files. Thanks none the less.

"Smallweed" wrote:

Not sure if it's possible. The following is how I do that sort of thing - it
captures the file path which you can then feed into other routines (the If is
there to stop users picking more than one file - you may want to let them!):

Sub ReturnFile()
Dim dlg As FileDialog
Dim strPath As String

OpenAgain:
Set dlg = Application.FileDialog(msoFileDialogFilePicker)
With dlg
If .Show = -1 Then
If .SelectedItems.Count 1 Then
MsgBox "You must open only one file."
GoTo OpenAgain
End If
strPath = .SelectedItems(1)
Else
Exit Sub
End If
End With
Set dlg = Nothing
MsgBox strPath
End Sub

"FallenFigLeaf" wrote:

I am calling xlDialogImportTextFile, selecting the txt file to import, and
then manipulating the imported data.

How do I capture the name of the txt file I selected to import and still use
xlDialogImportTextFile?

  #5   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 3
Default xlDialogImportTextFile txt file name

Yes, I tried this approach previously to find that even though it limits file
choices to txt, and captures the path, it does not launch the Import
function. Too bad.

"Smallweed" wrote:

Try: strFile = Application.GetOpenFilename("Text Files (*.txt), *.txt")

"FallenFigLeaf" wrote:

Many thanks,
Unfortunately, this routine does not launch the txt import process, and
since the file of interest is a txt, it does not open as a "workbook" or as
anything. Your routine works great for xl files, by capturing the path, but
not for other types of files. Thanks none the less.

"Smallweed" wrote:

Not sure if it's possible. The following is how I do that sort of thing - it
captures the file path which you can then feed into other routines (the If is
there to stop users picking more than one file - you may want to let them!):

Sub ReturnFile()
Dim dlg As FileDialog
Dim strPath As String

OpenAgain:
Set dlg = Application.FileDialog(msoFileDialogFilePicker)
With dlg
If .Show = -1 Then
If .SelectedItems.Count 1 Then
MsgBox "You must open only one file."
GoTo OpenAgain
End If
strPath = .SelectedItems(1)
Else
Exit Sub
End If
End With
Set dlg = Nothing
MsgBox strPath
End Sub

"FallenFigLeaf" wrote:

I am calling xlDialogImportTextFile, selecting the txt file to import, and
then manipulating the imported data.

How do I capture the name of the txt file I selected to import and still use
xlDialogImportTextFile?

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
File:1 and File:2 -- Double Files when Opening One File dallin Excel Discussion (Misc queries) 1 January 25th 07 02:53 AM
I saved file A over file B. Can I get file B back? Lynn Excel Discussion (Misc queries) 2 May 12th 06 11:24 AM
opening an excel file opens a duplicate file of the same file skm Excel Discussion (Misc queries) 1 December 7th 05 05:52 PM
I SAVED A FILE OVER ANOTHER A FILE IN EXCEL. THE OLD FILE WAS AN . DUFFER8MCD Excel Discussion (Misc queries) 1 December 23rd 04 11:32 PM
i received a file that reads powerpoint document file file exten. CCAROLACEREC Excel Discussion (Misc queries) 1 December 4th 04 05:02 PM


All times are GMT +1. The time now is 01:14 PM.

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

About Us

"It's about Microsoft Excel"