プロが教える店舗&オフィスのセキュリティ対策術

クエリ出力は以下でできたのですが、
ワークシート名がQ_testのみで上書きになります。
Excel出力時に、Q_testxx (x=月)にしたいです。

Function M_test()
On Error GoTo M_test_Err

DoCmd.TransferSpreadsheet acExport, 8, "Q_test", "c:\test.xls", False, ""

M_test_Exit:
Exit Function

M_test_Err:
MsgBox Error$
Resume M_test_Exit

End Function

A 回答 (1件)

なぜ、Function モジュールにしているか?ですが。


Function M_test()
On Error GoTo M_test_Err

'DoCmd.TransferSpreadsheet acExport, 8, "Q_test", "c:\test.xls", False, ""
'↓
docmd.TransferSpreadsheet acExport,acSpreadsheetTypeExcel8 _
,"Q_test","c:\test.xls",hasfieldnames:=false,range:="Q_test" & format(month(date()),"mm")

M_test_Exit:
Exit Function

M_test_Err:
MsgBox Error$
Resume M_test_Exit

End Function

では?
    • good
    • 0

お探しのQ&Aが見つからない時は、教えて!gooで質問しましょう!