如何在特定文件夹中创建文本文件并使用Print#statement.folder写入文件可以使用浏览按钮进行选择

时间:2017-11-27 16:32:40

标签: excel-vba vba excel

我想在特定文件夹中创建一个文本文件。使用浏览按钮选择文件夹路径,路径将存储在字符串变量中。现在我想在该路径中创建一个文本文件,我想使用Print #语句写入它。

Sub textfile()
    Dim FilePath As String
    'What is the file path 
    FilePath = "C:\Users\Chandu\Desktop\VBA\"

    'Now I want to create a text file like temp.h in the above path.

    Open "FilePath &""temp.h"" For Output As TextFile `enter code here`
        'Write some lines of text
        Print #1, "entering into VBA"
    Close #1
End Sub

0 个答案:

没有答案