Home |
Search |
Today's Posts |
|
#1
![]()
Posted to microsoft.public.excel.programming
|
|||
|
|||
![]()
I need to import a fixed width text file on a daily basis. The format will
always be the same but the title is different. The text file will always be in the same folder on my computer. I have tried recording a macro using the import wizard, but it hard codes the file name. How can I add something to prompt me for the file name? Thanks for your help! -- maryj |
#2
![]()
Posted to microsoft.public.excel.programming
|
|||
|
|||
![]()
On Jun 2, 1:14*pm, maryj wrote:
I need to import a fixed width text file on a daily basis. The format will always be the same but the title is different. The text file will always be in the same folder on my computer. I have tried recording a macro using the import wizard, but it hard codes the file name. How can I add something to prompt me for the file name? Thanks for your help! -- maryj Try incorporating Application.GetOpenFilename. Set a string variable equal to that and then replace the hard coded filename with the variable name. |
#3
![]()
Posted to microsoft.public.excel.programming
|
|||
|
|||
![]()
Option Explicit
Sub Testme01() Dim myFileName As Variant myFileName = Application.GetOpenFilename(filefilter:="Text Files, *.Txt", _ Title:="Pick a File") If myFileName = False Then MsgBox "Ok, try later" 'user hit cancel Exit Sub End If Workbooks.OpenText Filename:=myFileName '....rest of recorded code here! End Sub maryj wrote: I need to import a fixed width text file on a daily basis. The format will always be the same but the title is different. The text file will always be in the same folder on my computer. I have tried recording a macro using the import wizard, but it hard codes the file name. How can I add something to prompt me for the file name? Thanks for your help! -- maryj -- Dave Peterson |
#4
![]()
Posted to microsoft.public.excel.programming
|
|||
|
|||
![]()
Thanks Dave! Works perfect!
-- maryj "Dave Peterson" wrote: Option Explicit Sub Testme01() Dim myFileName As Variant myFileName = Application.GetOpenFilename(filefilter:="Text Files, *.Txt", _ Title:="Pick a File") If myFileName = False Then MsgBox "Ok, try later" 'user hit cancel Exit Sub End If Workbooks.OpenText Filename:=myFileName '....rest of recorded code here! End Sub maryj wrote: I need to import a fixed width text file on a daily basis. The format will always be the same but the title is different. The text file will always be in the same folder on my computer. I have tried recording a macro using the import wizard, but it hard codes the file name. How can I add something to prompt me for the file name? Thanks for your help! -- maryj -- Dave Peterson |
Reply |
Thread Tools | Search this Thread |
Display Modes | |
|
|
![]() |
||||
Thread | Forum | |||
Fixed Width Text Import Settings | Excel Discussion (Misc queries) | |||
Repeatable Fixed Width Import | Excel Discussion (Misc queries) | |||
HOW DO YOU SET THE DEFAULT FIXED COLOMN WIDTH ON THE EXCEL IMPORT | Excel Discussion (Misc queries) | |||
import fixed width text file | Excel Programming | |||
Import *.asc file into excel fixed width | Excel Programming |