Import/Export of .txt files using macro

  • Thread starter Thread starter jcb
  • Start date Start date
J

jcb

When creating the macro for the import/export of .txt
files it seems I have to enter the specific file name at
the macro build stage.

Can I open a dialogue box for my users to specifiy the
relevant .txt file for import/export at that time? If
so, how?

Thanks
 
You could add a text field on your form where the user
could type in the file name. In the macro for the file
name use
=[Forms]![NameOfForm]![NameOfTextbox]

or

You could get fancier and use the File dialog box.
In an unbound text box add this to the OnClick event. This
one i filter Excel files only.

Private Sub MyFilePath_Click()
Dim strFilter As String
Dim strInputFileName As String

strFilter = ahtAddFilterItem(strFilter, "Excel Files
(*.XLS)", "*.XLS")
Me.MyFilePath = ahtCommonFileOpenSave( _
Filter:=strFilter, OpenFile:=True, _
DialogTitle:="Please select an input
file...", _
Flags:=ahtOFN_HIDEREADONLY)
' Me.MyFilePath = strInputFileName

End Sub

Both options work

Jim
 
Back
Top