The code below demonstrates how I wanted to create a new txt file name. But apparently, GetOpenFilename works only for existing files.
(That is, when I enter a non-existing file name, I get the error "File not found".)
How can I get an API like GetOpenFilename, but for entering non-existing (or existing) file names?
(That is, when I enter a non-existing file name, I get the error "File not found".)
How can I get an API like GetOpenFilename, but for entering non-existing (or existing) file names?
Rich (BB code):
Option Explicit
Sub testit()
Dim fdOut As Integer, path As String
On Error Resume Next
path = Application.GetOpenFilename(Title:="Open new OUTPUT file")
If path = "" Or path = "False" Then Exit Sub
MsgBox path
On Error GoTo 0
fdOut = FreeFile
Open path For Output Access Write As #fdOut
MsgBox "open okay"
' [... write to file ...]
Close #fdOut
End Sub