Open Dialog..! in vb code..!

A

Andrew

I want to read a CSV file(using Open/Read etc), and parse the file in
code to set certain cell values...

1) How can i use an xlOpenDialog dialog box to allow the user to
select a CSV file
2) Return the name of the selected file into a variable.


I don't want to have to build a userform, and if possible use the
Application.Dialogs(xlOpenDialog) function.
I'm sure ive used this method before, but am unable to find it in my
archives.

Any Feedback is always appreciated.
Thankyou for your time.

Andrew
 
J

Jim Thomlinson

Try this...

Dim strFileName As String

strFileName = Application.GetOpenFilename("Text Files (*.csv), *.csv")
 
J

Jim Thomlinson

Sorry I should have elaborated on why I chose to use GetOpenfilename. You can
use

Application.Dialogs(xlDialogOpen).Show "*.csv"

But that opens the file. It does not return the name to a variable. I assume
you did not intend to open the CSV.
 
A

Andrew

Thanx Jim, did the trick exactly.

message | Try this...
|
| Dim strFileName As String
|
| strFileName = Application.GetOpenFilename("Text Files (*.csv),
*.csv")
|
| --
| HTH...
|
| Jim Thomlinson
|
|
| "Andrew" wrote:
|
| > I want to read a CSV file(using Open/Read etc), and parse the file
in
| > code to set certain cell values...
| >
| > 1) How can i use an xlOpenDialog dialog box to allow the user to
| > select a CSV file
| > 2) Return the name of the selected file into a variable.
| >
| >
| > I don't want to have to build a userform, and if possible use the
| > Application.Dialogs(xlOpenDialog) function.
| > I'm sure ive used this method before, but am unable to find it in
my
| > archives.
| >
| > Any Feedback is always appreciated.
| > Thankyou for your time.
| >
| > Andrew
| >
| >
| >
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top