accessからexcelを起動して印刷してファイルを消すフォーム
以下のコードをビルダに記述
Option Compare Database
Private Sub コマンド0_Click()
On Error GoTo Err_コマンド0_Click
Dim oApp As Object
Set oApp = CreateObject("Excel.Application")
oApp.Visible = True
'Only XL 97 supports UserControl Property
On Error Resume Next
oApp.UserControl = True
oApp.Workbooks.Open FileName:="C:\test.xls"
oApp.Range("B4").Value = "testテスト"
oApp.ActiveWindow.SelectedSheets.PrintOut Copies:=1, Collate:=True
oApp.DisplayAlerts = False
' oApp.Workbooks.Save
oApp.Workbooks.Close SaveChanges:=False
oApp.DisplayAlerts = False
oApp.Quit
Set oApp = Nothing
Kill "c:\test.xls"
Exit_コマンド0_Click:
Exit Sub
Err_コマンド0_Click:
MsgBox Err.Description
Resume Exit_コマンド0_Click
End Sub
Private Sub 詳細_Click()
End Sub
最終更新:2009年07月15日 11:03