有什么我需要参考的吗?我该如何使用:
Dim fso As New FileSystemObject
Dim fld As Folder
Dim ts As TextStream
Run Code Online (Sandbox Code Playgroud)
我收到错误,因为它无法识别这些对象.
我在其中一个工作表上有一个按钮,允许用户继续执行任务,将他/她的模板保存为文件夹中的单独工作簿.
这是我的代码
Private Sub ContinueButton_Click()
Application.ScreenUpdating = 0
Sheets(cmbSheet.Value).Visible = True
Application.Goto Sheets(cmbSheet.Value).[a22], True
Application.ScreenUpdating = 1
Unload Me
End Sub
Run Code Online (Sandbox Code Playgroud)
现在我需要的是检查该文件夹是否存在,如果该文件夹不存在,我的用户应该能够创建它.
我创建此文件夹的代码如下所示,但是如何将这两个函数连接在一起我根本不知道,因为我对VBA还不熟悉
Sub CreateDirectory()
Dim sep As String
sep = Application.PathSeparator
'sets the workbook's path as the current directory
ChDir ThisWorkbook.Path
MsgBox "The current directory is:" & vbCrLf & CurDir
'makes new folder in current directory
MkDir CurDir & sep & Settings.Range("C45").Value
MsgBox "The archive directory named " & Settings.Range("C45").Value & " has been created. The path to your …Run Code Online (Sandbox Code Playgroud)