Import/Export of .txt files using macro

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
 
J

Jim/Chris

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
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top