opening text files

birdman

Board Regular
Joined
Oct 11, 2005
Messages
187
i am using the code
Code:
Dim FileName as String
FileName = Application.GetOpenFilename
to receive the name of a file that will eventually be opened. the file that will be opened must be a text file. does anyone know how to have only text files appear when the open box appears? thanks for any help in advance.
 

Some videos you may like

Excel Facts

Show numbers in thousands?
Use a custom number format of #,##0,K. Each comma after the final 0 will divide the displayed number by another thousand

birdman

Board Regular
Joined
Oct 11, 2005
Messages
187
shuld have looked in help first. sorry about that. thanks for the help.
 

Norie

Well-known Member
Joined
Apr 28, 2004
Messages
76,061
Office Version
  1. 365
Platform
  1. Windows
Try this.
Code:
MyFileName = Application.GetOpenFilename("Text Files (*.txt), *.txt")
By the way you shouldn't declare the filename as String as it will generate a type mismatch if Cancel is pressed.
 

Watch MrExcel Video

Forum statistics

Threads
1,118,735
Messages
5,573,916
Members
412,555
Latest member
mark84
Top