0

我有word文档。我想在打开此文档时创建一个文本文件。如何使用宏创建文本文件?

4

1 回答 1

2

尝试这个。Document_Open()您可以在事件中创建文本文件

Private Sub Document_Open()
    Dim filesize As Integer
    Dim FlName As String

    FlName = "C:\Sample.Txt"

    '~~> get a free file handle
    filesize = FreeFile()

    '~~> Open your file
    Open FlName For Output As #filesize

    '~~> Export Text
    Print #filesize, "Hello World"
    Close #filesize
End Sub
于 2012-07-31T13:29:37.683 回答