Home |
Search |
Today's Posts |
#1
Posted to microsoft.public.excel.programming
|
|||
|
|||
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
Posted to microsoft.public.excel.programming
|
|||
|
|||
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 |
Display Modes | |
|
|
Similar Threads | ||||
Thread | Forum | |||
Defining user access (via user id) using macros | Excel Discussion (Misc queries) | |||
defining an array for INDEX | Excel Discussion (Misc queries) | |||
Help defining a user-defined function | New Users to Excel | |||
Defining an array to search by | Excel Discussion (Misc queries) | |||
CELL that picks up or inserts text with formula | Excel Discussion (Misc queries) |