我想输文件名之后点确定,就创建一个相应文件名的TXT文件。
我的代码如下: Private Sub 新建m_Click() CommonDialog4.Filter = "txt files(*.txt)" FileName = GetFileName("输入文件名!") 'FileNum = FileOpener(FileName, conRandomFile (As Integer, Len(Employee), Confirm) ' FileIOFrame.Enabled = True CreateAfile 'CommonDialog4.ShowNew End Sub Sub CreateAfile() '创建一个文件 Set fs = CreateObject("Scripting.FileSystemObject") Path = "f:\1\ " & FileName & ".txt" Set C = fs.CreateTextFile(Path, True) C.WriteLine ("This is a test.") C.Close End Sub Function GetFileName(Prompt As String) As String GetFileName = LTrim(RTrim(UCase(InputBox(Prompt, "Enter File Name")))) End Function
|