LoginSignup
2
1

More than 5 years have passed since last update.

クエリを指定してExcel形式でファイルのエクスポートを行う

Last updated at Posted at 2012-05-11
nyan.vb

Private Sub export_Click()

Dim W1 As Long
Dim OUT_FILE As String
Dim CUR_FLD As String
Dim Q_NAME As String

Q_NAME = "query_name"

If DCount("*", Q_NAME) = 0 Then
   MsgBox "レコードが存在しません。" & vbCrLf & "処理を中止します。"
Exit Sub
End If

CUR_FLD = Left(CurrentDb.name, InStrRev(CurrentDb.name, "\"))

WizHook.Key = 51488399
W1 = WizHook.GetFileName(0, "", "", "", OUT_FILE, CUR_FLD, "xlsxファイル(*.xlsx)|*.xlsx", 0, 0, 4, False)
WizHook.Key = 0

If W1 <> 0 Then
Exit Sub
End If

DoCmd.TransferSpreadsheet acExport, 10, Q_NAME, OUT_FILE

End Sub

2
1
0

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
2
1