LinkBack Thread Tools Search this Thread Display Modes
Prev Previous Post   Next Post Next
  #4   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 24
Default VBA Select File

Much appreciated. I had to do a minor change to the sub routine it was
calling to deal with a single file instead of a group. But this works!

THANK YOU!
--
Linda


"Dave Peterson" wrote:

Maybe...

Sub GetSingleFile()
dim DestSht as string
dim myFileName as variant

myfilename = application.getopenfilename
if myfilename = false then
'user hit cancel
exit sub
end if

DestSht = "sheet1"
With ThisWorkbook.Sheets(DestSht)
SearchData = .Range("A1").Text
End With

Call ReadCSV(myfilename, SearchData, DestSht)

End Sub

myFileName will be False (the boolean) if the user hits cancel. It will include
the path and filename if the user selects a file.


L.Mathe wrote:

I am using Excel 2003. I have a workbook that runs a macro to search through
all files in a folder for specific text, and extract that text into the
worksheet. I need to create another macro where just a single file can be
selected then extract the data from the one file only. I tried to modify the
VBA, but run into an error code 'Object Required'. What I attempted to do
was:

Sub GetSingleFile()

DestSht = "sheet1"
With ThisWorkbook.Sheets(DestSht)
SearchData = .Range("A1").Text
End With

Dim fd As FileDialog
Set fd = Application.GetOpenFilename
Dim vrtSelectedItem As Variant
With fd
If .Show = -1 Then
Call ReadCSV(Folder, SearchData, DestSht)

End If
End With

Set fd = Nothing
End Sub

I have not included the Sub routine here, possibly that is where the problem
is. Could someone please help with this VBA?

Thank you!
--
Linda


--

Dave Peterson
.

 
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
Select File names and select a location of file pokdbz Excel Programming 1 August 3rd 07 10:10 PM
open file dialog-select file-import worksheet Divinedar Excel Programming 1 January 16th 04 07:13 PM
Prompt user to select file with default file selected dialog Bruce Cooley Excel Programming 0 September 15th 03 06:43 AM
Prompt user to select file with default file selected dialog Bob Phillips[_5_] Excel Programming 0 September 14th 03 09:22 PM
Prompt user to select file with default file selected dialog Bob Phillips[_5_] Excel Programming 0 September 14th 03 09:19 PM


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