Home |
Search |
Today's Posts |
#1
|
|||
|
|||
add browser menu in excel
I have a spread sheet that reads data in from a text file before I use it.
Just now I have the user add the text file pathname in a cell and I use that pathname. I would like to add a browser capability where the user can select the file just like windows explorer. Can't find anything to do this. Any help is appreciated. Thanks |
#2
|
|||
|
|||
You could use a little macro and ask the user to select the input file. (Are
you importing the text file via a macro?) Dim myFileName as variant myfilename = application.getopenfilename("Text Files, *.txt") if myfilename = false then exit sub 'user hit cancel end if 'then open that myFilename I like to record a macro to get all the parms/columns correct. My line of recorded code looks like: Workbooks.OpenText Filename:="C:\My Documents\excel\Edit3.txt", _ Origin:=437, StartRow:=1, DataType:=xlFixedWidth, _ FieldInfo:=Array(Array(0, 1), Array(7, 1), Array(13, 1), _ Array(20, 1), Array(27, 1), Array(33, 1), Array(39, 1)) Your recorded code would look different. But then you could modify that recorded code to use the filename specified by the user: Workbooks.OpenText Filename:=myFileName, _ Origin:=437, StartRow:=1, DataType:=xlFixedWidth, _ FieldInfo:=Array(Array(0, 1), Array(7, 1), Array(13, 1), _ Array(20, 1), Array(27, 1), Array(33, 1), Array(39, 1)) And continue with the rest of your code. scottish_warrior wrote: I have a spread sheet that reads data in from a text file before I use it. Just now I have the user add the text file pathname in a cell and I use that pathname. I would like to add a browser capability where the user can select the file just like windows explorer. Can't find anything to do this. Any help is appreciated. Thanks -- Dave Peterson |
#3
|
|||
|
|||
Thanks,
Works perfectly. I already was importing the file via a macro just couldn't find a way to graphically select the file. Thanks again. "Dave Peterson" wrote: You could use a little macro and ask the user to select the input file. (Are you importing the text file via a macro?) Dim myFileName as variant myfilename = application.getopenfilename("Text Files, *.txt") if myfilename = false then exit sub 'user hit cancel end if 'then open that myFilename I like to record a macro to get all the parms/columns correct. My line of recorded code looks like: Workbooks.OpenText Filename:="C:\My Documents\excel\Edit3.txt", _ Origin:=437, StartRow:=1, DataType:=xlFixedWidth, _ FieldInfo:=Array(Array(0, 1), Array(7, 1), Array(13, 1), _ Array(20, 1), Array(27, 1), Array(33, 1), Array(39, 1)) Your recorded code would look different. But then you could modify that recorded code to use the filename specified by the user: Workbooks.OpenText Filename:=myFileName, _ Origin:=437, StartRow:=1, DataType:=xlFixedWidth, _ FieldInfo:=Array(Array(0, 1), Array(7, 1), Array(13, 1), _ Array(20, 1), Array(27, 1), Array(33, 1), Array(39, 1)) And continue with the rest of your code. scottish_warrior wrote: I have a spread sheet that reads data in from a text file before I use it. Just now I have the user add the text file pathname in a cell and I use that pathname. I would like to add a browser capability where the user can select the file just like windows explorer. Can't find anything to do this. Any help is appreciated. Thanks -- Dave Peterson |
Reply |
Thread Tools | Search this Thread |
Display Modes | |
|
|
Similar Threads | ||||
Thread | Forum | |||
How do I isolate my Excel server (automation) from other Excel instances? | Excel Discussion (Misc queries) | |||
how to convert GETPIVOTDATA from excel 2000 to excel 2002... | Excel Worksheet Functions | |||
Excel error - Startup (and Acrobat PDFMaker) | Setting up and Configuration of Excel | |||
VB Automation is Whacking out my Excel Environment | Excel Discussion (Misc queries) | |||
Save & Save As features in file menu of Excel | Excel Discussion (Misc queries) |