我能否获取 Access 以自动命名文件导出,其中包含文件名的可变部分和文件名的固定部分
Can I get Access to automatically name a file export with a variable part of the file name and a fixed part of the filename
我正在使用 Access 2014 数据库将查询结果导出到 excel 文件,该文件可以发送给第三方。我希望生成的 excel 文件转到共享驱动器上的指定文件夹,命名方案为 "serialnumber vendor ASL.xlsx"
任何我应该查看的提示,指向我没有通过 Duck Duck Go 找到的网站的指针,都将不胜感激
现在我正在使用一个简单的宏来导出带有 "ExportWithFormatting" 的文件,但我似乎无法在 "Output File" 框中进行任何操作,这给我带来了任何灵活性。
我怀疑这可以用 VBS 来完成,但在建立和 运行 VBS 模块时我很犹豫。我将宏转换为 VBS 模块,但我不知道从这里去哪里。
Option Compare Database
'------------------------------------------------------------
' expord_ASL_to_Excel
'
'------------------------------------------------------------
Function expord_ASL_to_Excel()
On Error GoTo expord_ASL_to_Excel_Err
DoCmd.OutputTo acOutputQuery, "Match up", "ExcelWorkbook(*.xlsx)", "", True, "", , acExportQualityPrint
expord_ASL_to_Excel_Exit:
Exit Function
expord_ASL_to_Excel_Err:
MsgBox Error$
Resume expord_ASL_to_Excel_Exit
End Function
我对它进行了一些修改,但我无法让它执行任何操作。我目前正在尝试回溯 运行 VBS 模块的基础知识,因此我还不需要任何帮助。我只是想弄清楚这一点技巧。
根据 OP 的评论,Vendor 和 Serial 是从 Form 的 ComboBoxes 中选择的。
这段代码应该放在模块中——覆盖那里的函数。它可以通过 Macro - RunCode 触发,或者您可以 link 一个按钮直接点击它。
只需将 networkPath 值替换为您希望文件结束的文件夹(包括最后一个)。
然后将 Form("Form1") 和 ComboBox("SerialComboBox", "VendorComboBox") 名称替换为您的窗体和控件的名称。
Function expord_ASL_to_Excel()
On Error GoTo expord_ASL_to_Excel_Err
Dim networkPath As String
networkPath = "C:\Your\Network\Path\"
exportPath = networkPath & Forms!Form1!SerialComboBox.Value & " " & Forms!Form1!VendorComboBox.Value & " ASL.xlsx"
DoCmd.OutputTo acOutputQuery, "Match up", "ExcelWorkbook(*.xlsx)", exportPath, True, "", , acExportQualityPrint
expord_ASL_to_Excel_Exit:
Exit Function
expord_ASL_to_Excel_Err:
MsgBox Error$
Resume expord_ASL_to_Excel_Exit
End Function
这个解决方案对我很有帮助。稍作修改,它对我有用。谢谢你们。我需要帮助将过滤器应用于报告,然后将过滤后的值用作学科(光盘)值。
Function exportPDF()
On Error GoTo exportPDF_Err
Dim Report_Names() As String
Dim MyReport As String
Dim networkPath As String
Dim LDate As String
Dim LYear As Integer
Dim LMonth As Integer
Dim LDay As Integer
Dim Discipline As String
MyExport = Reports!rptCurrentWK
LDate = Date
LYear = Year(LDate)
LMonth = Month(LDate)
LDay = Day(MyExport!WEdate)
Disc = MyExport!Discipline.Value
networkPath = "C:\Users\MSS\Drive\Timesheets\Access Export\"
exportPath = networkPath & "Timesheet-" & Disc & "_WE_" & LYear &
"-" & LMonth & "-" & LDay & ".PDF"
DoCmd.OutputTo acOutputReport, "rptCurrentWK", "PDFFormat(*.pdf)", exportPath,
False, "", , acExportQualityPrint
exportPDF_Exit:
Exit Function
exportPDF_Err:
MsgBox Error$
Resume exportPDF_Exit
End Function
我正在使用 Access 2014 数据库将查询结果导出到 excel 文件,该文件可以发送给第三方。我希望生成的 excel 文件转到共享驱动器上的指定文件夹,命名方案为 "serialnumber vendor ASL.xlsx"
任何我应该查看的提示,指向我没有通过 Duck Duck Go 找到的网站的指针,都将不胜感激
现在我正在使用一个简单的宏来导出带有 "ExportWithFormatting" 的文件,但我似乎无法在 "Output File" 框中进行任何操作,这给我带来了任何灵活性。
我怀疑这可以用 VBS 来完成,但在建立和 运行 VBS 模块时我很犹豫。我将宏转换为 VBS 模块,但我不知道从这里去哪里。
Option Compare Database
'------------------------------------------------------------
' expord_ASL_to_Excel
'
'------------------------------------------------------------
Function expord_ASL_to_Excel()
On Error GoTo expord_ASL_to_Excel_Err
DoCmd.OutputTo acOutputQuery, "Match up", "ExcelWorkbook(*.xlsx)", "", True, "", , acExportQualityPrint
expord_ASL_to_Excel_Exit:
Exit Function
expord_ASL_to_Excel_Err:
MsgBox Error$
Resume expord_ASL_to_Excel_Exit
End Function
我对它进行了一些修改,但我无法让它执行任何操作。我目前正在尝试回溯 运行 VBS 模块的基础知识,因此我还不需要任何帮助。我只是想弄清楚这一点技巧。
根据 OP 的评论,Vendor 和 Serial 是从 Form 的 ComboBoxes 中选择的。
这段代码应该放在模块中——覆盖那里的函数。它可以通过 Macro - RunCode 触发,或者您可以 link 一个按钮直接点击它。
只需将 networkPath 值替换为您希望文件结束的文件夹(包括最后一个)。
然后将 Form("Form1") 和 ComboBox("SerialComboBox", "VendorComboBox") 名称替换为您的窗体和控件的名称。
Function expord_ASL_to_Excel()
On Error GoTo expord_ASL_to_Excel_Err
Dim networkPath As String
networkPath = "C:\Your\Network\Path\"
exportPath = networkPath & Forms!Form1!SerialComboBox.Value & " " & Forms!Form1!VendorComboBox.Value & " ASL.xlsx"
DoCmd.OutputTo acOutputQuery, "Match up", "ExcelWorkbook(*.xlsx)", exportPath, True, "", , acExportQualityPrint
expord_ASL_to_Excel_Exit:
Exit Function
expord_ASL_to_Excel_Err:
MsgBox Error$
Resume expord_ASL_to_Excel_Exit
End Function
这个解决方案对我很有帮助。稍作修改,它对我有用。谢谢你们。我需要帮助将过滤器应用于报告,然后将过滤后的值用作学科(光盘)值。
Function exportPDF()
On Error GoTo exportPDF_Err
Dim Report_Names() As String
Dim MyReport As String
Dim networkPath As String
Dim LDate As String
Dim LYear As Integer
Dim LMonth As Integer
Dim LDay As Integer
Dim Discipline As String
MyExport = Reports!rptCurrentWK
LDate = Date
LYear = Year(LDate)
LMonth = Month(LDate)
LDay = Day(MyExport!WEdate)
Disc = MyExport!Discipline.Value
networkPath = "C:\Users\MSS\Drive\Timesheets\Access Export\"
exportPath = networkPath & "Timesheet-" & Disc & "_WE_" & LYear &
"-" & LMonth & "-" & LDay & ".PDF"
DoCmd.OutputTo acOutputReport, "rptCurrentWK", "PDFFormat(*.pdf)", exportPath,
False, "", , acExportQualityPrint
exportPDF_Exit:
Exit Function
exportPDF_Err:
MsgBox Error$
Resume exportPDF_Exit
End Function