Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Wanet Telecoms Ltd on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Prompt for when importing a text file

Status
Not open for further replies.

stacy0966

Programmer
Apr 27, 2004
35
US
Hello,

I have setup a macro using the macro object. I am using the
"transfer text" action. The macro works fine but I would like for a box pop up that asks for the "filename" to import. I have been able to get this to work using "msgbox"; however, I would like the ability to browse for the path. Any suggestion would be greatly appreciated.

Thanks,

Stacy
 
You can't access browse using macros. There are very severe limitations to using macros over VBA. Primarily error checking but also advanced functionality. Now watch some macro guru come up with a way.

---------------------
scking@arinc.com
---------------------
 
Public Function GetFile() As String

Dim GetFileDialogue As Office.FileDialog
Dim path As String
Set GetFileDialogue = Application.FileDialog(msoFileDialogFilePicker)
With GetFileDialogue
'Set the title of the dialog box.
.Title = "Please select your file"

'enter your file type filters here
.Filters.Clear
.Filters.Add "All Files", "*.*"



If .Show = True Then
path = .SelectedItems(1)

Else
Exit Function

End If
End With

GetFile = path
'Debug.Print GetFile

End Function

copy that into a module and call the getfile function using the runfunction macro command. The GetFile function will return the full file path of the file you selected

The above is slightly tweaked from a small VBA function i use to read files into a string.

I can provide you with this function / how to use it if you want to take a VBA approach. Which i would recommend

HAving said that i would also recommend tinkering yourself as its the best way to learn
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top