Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 27,285
Default User picks a text file, macro defining the array

Dim fName as Variant
ChDir "C:\Documents and Settings\RRadmacher\My Documents\Productivity"
fname = Application.GetOpenFileName(FileFilter:= "Text Files (*.txt),*.txt")
if fName < False then
Workbooks.OpenText Filename:=fName, _
Origin:=xlWindows, _
StartRow:=1, _
DataType:=xlFixedWidth, _
FieldInfo:=Array( _
Array(0, 1), Array(15,1), _
Array(47, 1), Array(93, 1), _
Array(125, 1), Array(134, 1), _
Array(150, 1), Array(172, 1)), _
TrailingMinusNumbers:=True
End if

--
Regards,
Tom Ogilvy


"melric" wrote in message
...
I have a macro that opens a text file and starts manipulating the data in

it.
I recorded the macro by opening a specific file and setting each column.
I want the macro to ask me (via a dialog box) which text file I want to
open, once I choose the file, I want the macro to apply the correct array

and
formatting.

The current language I'm using is:

ChDir "C:\Documents and Settings\RRadmacher\My Documents\Productivity"
Workbooks.OpenText Filename:= _
"C:\Documents and Settings\RRadmacher\My
Documents\Productivity\picks.txt", Origin:=xlWindows, StartRow _
:=1, DataType:=xlFixedWidth, FieldInfo:=Array(Array(0, 1),

Array(15,
1), Array _
(47, 1), Array(93, 1), Array(125, 1), Array(134, 1), Array(150,

1),
Array(172, 1)), _
TrailingMinusNumbers:=True

After this language, the macro begins manipulating the data on that file.

I want to tell the program which directory and file to grab (it will be a
different text file each day, instead of having one file defined in the

macro?
Thanks



  #2   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 27,285
Default User picks a text file, macro defining the array

Look in help at Application.GetSaveAsFileName. This returns a string with
the fully qualified path for the specified file name. You then use this
with

fName = Application.GetSaveAsFileName( see help for args)
if fName < False then
activeworkbook.SaveAs fName
End If

--
Regards,
Tom Ogilvy


"melric" wrote in message
...
It worked!!!!!
Now, one mo
When my macro is done, I'd like another dialog window to pop up asking me
what I'd like to save the file as. (If it defaults to save as an excel
spreadsheet, all the better.) Thanks for the help.

"Tom Ogilvy" wrote:

Dim fName as Variant
ChDir "C:\Documents and Settings\RRadmacher\My Documents\Productivity"
fname = Application.GetOpenFileName(FileFilter:= "Text Files

(*.txt),*.txt")
if fName < False then
Workbooks.OpenText Filename:=fName, _
Origin:=xlWindows, _
StartRow:=1, _
DataType:=xlFixedWidth, _
FieldInfo:=Array( _
Array(0, 1), Array(15,1), _
Array(47, 1), Array(93, 1), _
Array(125, 1), Array(134, 1), _
Array(150, 1), Array(172, 1)), _
TrailingMinusNumbers:=True
End if

--
Regards,
Tom Ogilvy


"melric" wrote in message
...
I have a macro that opens a text file and starts manipulating the data

in
it.
I recorded the macro by opening a specific file and setting each

column.
I want the macro to ask me (via a dialog box) which text file I want

to
open, once I choose the file, I want the macro to apply the correct

array
and
formatting.

The current language I'm using is:

ChDir "C:\Documents and Settings\RRadmacher\My Documents\Productivity"
Workbooks.OpenText Filename:= _
"C:\Documents and Settings\RRadmacher\My
Documents\Productivity\picks.txt", Origin:=xlWindows, StartRow _
:=1, DataType:=xlFixedWidth, FieldInfo:=Array(Array(0, 1),

Array(15,
1), Array _
(47, 1), Array(93, 1), Array(125, 1), Array(134, 1),

Array(150,
1),
Array(172, 1)), _
TrailingMinusNumbers:=True

After this language, the macro begins manipulating the data on that

file.

I want to tell the program which directory and file to grab (it will

be a
different text file each day, instead of having one file defined in

the
macro?
Thanks






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
Defining user access (via user id) using macros maruko Excel Discussion (Misc queries) 0 July 27th 09 02:44 AM
defining an array for INDEX Dave F[_2_] Excel Discussion (Misc queries) 1 October 2nd 07 07:51 PM
Help defining a user-defined function LurfysMa New Users to Excel 7 June 10th 07 07:46 AM
Defining an array to search by Justlearnin Excel Discussion (Misc queries) 4 April 25th 07 04:59 PM
CELL that picks up or inserts text with formula MikeR-Oz Excel Discussion (Misc queries) 2 February 26th 06 10:41 AM


All times are GMT +1. The time now is 07:33 PM.

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"