![]() |
![]() |
|
|||||||
| Excel Questions All Excel/VBA questions - formulas, macros, pivot tables, general help, etc. Please post to this forum in English only. |
![]() |
|
|
Thread Tools | Display Modes |
|
|
#1 |
|
New Member
Join Date: May 2002
Posts: 48
|
I have created a macro to open a text file and set the columns,widthes,types etc. It works fine except it always opens the same file.
How do I make it so the user can select the file name to open. Currently it only opens the one file name used when I created the macro. Is there some sort of pause command I can insert into the macro? |
|
|
|
|
|
#2 | |
|
Board Regular
Join Date: Apr 2002
Posts: 112
|
Quote:
|
|
|
|
|
|
|
#3 |
|
MrExcel MVP, Administrator
Join Date: Feb 2002
Location: The act or process of locating.
Posts: 13,679
|
I got some help with something along those lines a little while back.
Try adding this to your code instead of opening the one file:
This is what worked for me when I wanted it to bring up the open dialog box and let someone choose the files they want to open. Hope this helps, _________________ ~*Kristy*~ "Catapultam habeo. Nisi pecuniam omnem mihi dabis, ad caput tuum saxum immane mittam." [ This Message was edited by: Von Pookie on 2002-05-07 11:27 ] |
|
|
|
|
|
#4 | |
|
Board Regular
Join Date: Feb 2002
Posts: 76
|
Quote:
dim FileName as String FileName = Application.GetOpenFilename("Text Files (*.txt), *.txt") |
|
|
|
|
|
|
#5 |
|
New Member
Join Date: May 2002
Posts: 48
|
how would I insert that code into this?
Sub Macro2() ' ' Macro2 Macro ' Macro recorded 05/07/2002 by joe ' ' Workbooks.OpenText FileName:="T:Mcdrpswg01 |
|
|
|
![]() |
| Bookmarks |
| Thread Tools | |
| Display Modes | |
|
|