ExcelBanter

ExcelBanter (https://www.excelbanter.com/)
-   Excel Programming (https://www.excelbanter.com/excel-programming/)
-   -   Open Dialog..! in vb code..! (https://www.excelbanter.com/excel-programming/432265-open-dialog-vbulletin-code.html)

Andrew[_9_]

Open Dialog..! in vb code..!
 
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



Jim Thomlinson

Open Dialog..! in vb code..!
 
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




Jim Thomlinson

Open Dialog..! in vb code..!
 
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.
--
HTH...

Jim Thomlinson


"Jim Thomlinson" wrote:

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




Andrew[_9_]

Open Dialog..! in vb code..!
 
Thanx Jim, did the trick exactly.

"Jim Thomlinson" wrote in
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
|
|
|




All times are GMT +1. The time now is 01:44 AM.

Powered by vBulletin® Copyright ©2000 - 2025, Jelsoft Enterprises Ltd.
ExcelBanter.com