Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 220
Default Opening text files

I have an application that prompts the user to select a text file for
processing which is done by using the 'GetOpenFilename' from the
Microsoft Excel object library. I'm not using Excel in the program
so
I'm assuming this is probably not the best way to do this. Any
suggestions?

inputfile = Application.GetOpenFilename( _
fileFilter:="Text Files (*.txt),*.txt", _
Title:="Select the file")

Thanks,
-- Dan

  #2   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 2,718
Default Opening text files

I agree that using the Excel object model just for GetOpenFilename seems
overkill and requiring a user to have Excel installed for no other reason is
to be avoided.

Another approach is to use the Windows API. The downside is that it is a
lot more complex. This site has code specifically for standalone VB6 but
you could adapt it to VBA pretty easily I think.


http://vbnet.mvps.org/code/comdlg/fileopendlg.htm

--
Jim
"Dan R." wrote in message
oups.com...
|I have an application that prompts the user to select a text file for
| processing which is done by using the 'GetOpenFilename' from the
| Microsoft Excel object library. I'm not using Excel in the program
| so
| I'm assuming this is probably not the best way to do this. Any
| suggestions?
|
| inputfile = Application.GetOpenFilename( _
| fileFilter:="Text Files (*.txt),*.txt", _
| Title:="Select the file")
|
| Thanks,
| -- Dan
|


  #3   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 131
Default Opening text files

On XP systems you could try something like this:

Sub openTXT()

'XP only
Set cd = CreateObject _
("UserAccounts.CommonDialog")

cd.Filter = "Text Files|*.txt"
cd.InitialDir = "C:\"
If cd.ShowOpen = 0 Then
Exit Sub
End If

Debug.Print cd.Filename

End Sub

--
urkec


"Jim Rech" wrote:

I agree that using the Excel object model just for GetOpenFilename seems
overkill and requiring a user to have Excel installed for no other reason is
to be avoided.

Another approach is to use the Windows API. The downside is that it is a
lot more complex. This site has code specifically for standalone VB6 but
you could adapt it to VBA pretty easily I think.


http://vbnet.mvps.org/code/comdlg/fileopendlg.htm

--
Jim
"Dan R." wrote in message
oups.com...
|I have an application that prompts the user to select a text file for
| processing which is done by using the 'GetOpenFilename' from the
| Microsoft Excel object library. I'm not using Excel in the program
| so
| I'm assuming this is probably not the best way to do this. Any
| suggestions?
|
| inputfile = Application.GetOpenFilename( _
| fileFilter:="Text Files (*.txt),*.txt", _
| Title:="Select the file")
|
| Thanks,
| -- Dan
|



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
Opening text files Sandy5590 Excel Discussion (Misc queries) 0 October 15th 09 04:35 PM
opening extensionless text files T Magritte Excel Discussion (Misc queries) 2 July 23rd 08 07:54 PM
Opening large text files freekrill Excel Discussion (Misc queries) 6 September 7th 05 04:44 AM
Opening text files Jason Excel Programming 1 March 1st 04 02:23 AM
Opening text files using macro Ron de Bruin Excel Programming 0 July 9th 03 02:49 PM


All times are GMT +1. The time now is 08:12 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"