Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
scottish_warrior
 
Posts: n/a
Default 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   Report Post  
Dave Peterson
 
Posts: n/a
Default

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   Report Post  
scottish_warrior
 
Posts: n/a
Default

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
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
How do I isolate my Excel server (automation) from other Excel instances? Joseph Geretz Excel Discussion (Misc queries) 5 July 19th 13 03:18 PM
how to convert GETPIVOTDATA from excel 2000 to excel 2002... Need_help_on_excel Excel Worksheet Functions 1 March 15th 05 01:08 AM
Excel error - Startup (and Acrobat PDFMaker) gxdata Setting up and Configuration of Excel 0 February 4th 05 03:44 AM
VB Automation is Whacking out my Excel Environment Joseph Geretz Excel Discussion (Misc queries) 2 December 29th 04 03:49 PM
Save & Save As features in file menu of Excel Blue Excel Discussion (Misc queries) 9 December 27th 04 08:49 PM


All times are GMT +1. The time now is 07:23 AM.

Powered by vBulletin® Copyright ©2000 - 2024, Jelsoft Enterprises Ltd.
Copyright ©2004-2024 ExcelBanter.
The comments are property of their posters.
 

About Us

"It's about Microsoft Excel"