View Single Post
  #1   Report Post  
Posted to microsoft.public.excel.programming
Robert Crandal[_3_] Robert Crandal[_3_] is offline
external usenet poster
 
Posts: 161
Default Application.GetOpenFilename

This question actually involves Microsoft Word.....

The following code works in Excel, but it gives a compile
error in Word. Does anyone know why?

'--------------------------------------
Public Function MyFileDlg() As String
' This line fails in Word!
NewFN = Application.GetOpenFilename(FileFilter:="Text Files (*.txt), *.txt",
Title:="Please select a file")
If NewFN = False Then
MyFileDlg = ""
Else
MyFileDlg = NewFN
End If
End Function
'-------------------------
Sub Tester()
Dim str As String
str = MyFileDlg
MsgBox str
End Sub