![]() |
![]() |
|
|||||||
| 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 |
|
Guest
Posts: n/a
|
If I use the following code where do I put it? Can I attach it to a command button?
Sub GetImportFileName() 'Set up the file filters Filter = "Text Files (*.txt),*.txt," & _ "Lotus Files (*.prn),*.prn," & _ "Comma Separated Files (*.csv),*.csv," & _ "ASCII Files (*.asc), *.asc," & _ "All Files (*.*),*.*" 'Display *.* default FilterIndex = 5 'set dialog box caption Title = "Select a File to import" 'get filename FileName = Application.GetOpenFilename(Filter, _ FilterIndex, Title) 'Exit on cancel If FileName = Fales Then MsgBox = "No file selected" Exit Sub End If 'Open file Workbooks.Open FileName I'm trying to import a file and create a worksheet that I can pull data from. Thanks, |
|
|
|
#2 |
|
Board Regular
Join Date: Feb 2002
Location: Ontario, Canada
Posts: 326
|
In design mode right click on the button and select "view code" Paste your code here.
|
|
|
|
![]() |
| Bookmarks |
| Thread Tools | |
| Display Modes | |
|
|