目前,我在运行 VBA 的访问表单中有一个按钮。此 VBA 创建一个文件夹,然后将文件从 access db 导出到该文件夹中的 excel 文件中。代码是这样的:
MkDir CurrentProject.Path & "\W46"
Dim outputlot3mah As String
outputlot3mah = CurrentProject.Path & "\" & "W46" & "\" & "Lot03_MAHs.xls"
DoCmd.TransferSpreadsheet acExport, acSpreadsheetTypeExcel9, "Lot03_MAHs", outputlot3mah, True
有没有一种方法,当用户单击按钮时,他可以输入一个名称,这将是文件夹的名称?因此,例如,如果他选择 W78 作为名称,则文件夹命名为 W78,并且在该文件夹中输入文件。
那么它会是这样的
Dim getFolderName As String
MkDir CurrentProject.Path & getFolderName
Dim outputlot3mah As String
outputlot3mah = CurrentProject.Path & "\" & getFolderName & "\" & "Lot03_MAHs.xls"
DoCmd.TransferSpreadsheet acExport, acSpreadsheetTypeExcel9, "Lot03_MAHs", outputlot3mah, True
我是 VBA 新手,所以我不知道这是否可能。谢谢!