Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 284
Default Windows API - File Menu Processing...

JEB,

Give this a try. I tested on Excel 2003. In the example, I have a message
box display the value of vrtSelectedItem, you would change to do something
with the path to the txt file.

_________________________________________

Sub UserGetMyDocsFiles()

Dim fd As FileDialog
Dim vrtSelectedItem As Variant

' Determine Path to the My Documents folder
Set objShell = CreateObject("Shell.Application")
Set objMyDocsFldr = objShell.Namespace(&H5&)
strMyDocsPath = objMyDocsFldr.Self.Path

' Create a file picker dialog opening to My Documents
' Limit return to .txt files only one selection
Set fd = Application.FileDialog(msoFileDialogFilePicker)
With fd
..Filters.Clear
..Filters.Add "Text Documents", "*.txt"
..AllowMultiSelect = False
..Title = "Fetch the text file you want for XL"
..InitialFileName = strMyDocsPath
If .Show = -1 Then
For Each vrtSelectedItem In .SelectedItems
MsgBox vrtSelectedItem
Next vrtSelectedItem
End If
End With

Set objShell = Nothing
Set fd = Nothing

End Sub

_______________________________________


Steve Yandl



"JEB" wrote in message
...
Please excuse my lack of knowledge/understanding of the Windows API - I'm
totally confused.
I have an Excel application that calls for the user to import a text file.
At the moment I have confined the file name and path to hard code in VBA
(The
user MUST have a file called ABC.txt and it MUST reside in the c:\temp
directory. This is no longer acceptable.
I need to provide the functionality for the user to select the file from a
list in their My Documents directory (or sub directory), only limiting the
file name to .txt files.
What is the best and simplest way to approch this?
Thank you in advance.
JEB



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
Batch File drag-n-drop processing. Beav Excel Programming 3 January 25th 07 04:00 PM
File Processing Macros - Need Assistance Telecommm Excel Programming 0 December 22nd 05 09:25 AM
macro for processing one excel file and saving it to other shwetaparekh Excel Programming 1 September 30th 05 11:41 PM
Open Batch File For Processing Chuckles123[_79_] Excel Programming 4 July 15th 05 01:43 PM
Menu Editor /Windows Menu ed Excel Programming 1 December 8th 03 05:48 PM


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