我從MS Access表中導出文件到我的本地,我正在做這個VBA編碼。 我需要爲這樣的方式的文件名創建序列,如何創建序列
File1PN00001
File1PN00002
File1PN00003
...
...
我對下面的代碼
Private Sub Command0_Click()
Dim FileName As String
Dim intChoice As Integer
Dim strPath As String
Dim LSProc As QueryDef
Dim db As Database
Set db = CurrentDb()
Set LSProc = db.CreateQueryDef("")
'make the file dialog visible to the user
strFilePath = BrowseFolder("Please Select Path to Export Neutrality Report file to")
If strFilePath <> "" Then
Call MsgBox(strFilePath, vbInformation, "Save Path")
Else
MsgBox "Please Provide a file path before exporting!", vbCritical + vbOKOnly
End If
FileName = strFilePath & "File1PN" & Format(txtBal_Number, "000000") & ".txt"
DoCmd.TransferText acExportDelim, , "T1", FileName, False
End Sub
這樣做我很困惑如何創建該序列,如何創建序列以及如何在每次運行此代碼時將值增加1。您能否幫我解決這個問題 謝謝。
是否希望將DB中的所有表導出到txt文件? – PaulFrancis 2014-10-10 11:41:09
那麼,你需要找到那個目錄中最後保存的文件的編號。抓取數字部分並在保存時增加1? – 2014-10-10 11:49:32
@PaulFrancis:不,並非所有的表格只有那些需要的表格。這裏T1是輸出的表格 – 2014-10-10 12:01:10