S
SF
Hi,
I have developed the following code below. This code work fine except asking
user to save the opened worksheet when closing. I don't want user to save
any information at this stage, Is there a way to disable the message "Do you
want to save...", Yes, No Cancel...
Public Function PrintTravel(ID As Long)
Dim xlApp As Excel.Application
Dim xlBook As Excel.Workbook
Dim xlSheet As Excel.Worksheet
Dim dbs As DAO.Database
Dim rst As DAO.Recordset
Dim qdf As DAO.QueryDef
Dim Stg As String
'Dim I, J As Long
Dim NoDays As String
Dim FromTo As String
Stg = "SELECT Travels.*"
Stg = Stg & " FROM Travels"
Stg = Stg & " WHERE (((Travels.TravelID)=" & ID & "));"
Set dbs = CurrentDb
Set qdf = dbs.QueryDefs("Travels")
qdf.Parameters("ID") = ID
Set rst = qdf.OpenRecordset(dbOpenDynaset)
Set xlApp = CreateObject("Excel.Application")
xlApp.Visible = False
xlApp.Workbooks.Open "S:\General\LAAR\Database\Templates\AOT.XLS"
xlApp.Sheets(1).Cells(6, 5).Value = rst![Names]
xlApp.Sheets(1).Cells(7, 5).Value = rst![Purpose]
xlApp.Sheets(1).Cells(10, 5).Value = rst![Destination] & FromTo
xlApp.ActiveWorkbook.PrintOut
xlApp.ActiveWorkbook.Saved = False
xlApp.Quit
End Function
SF
I have developed the following code below. This code work fine except asking
user to save the opened worksheet when closing. I don't want user to save
any information at this stage, Is there a way to disable the message "Do you
want to save...", Yes, No Cancel...
Public Function PrintTravel(ID As Long)
Dim xlApp As Excel.Application
Dim xlBook As Excel.Workbook
Dim xlSheet As Excel.Worksheet
Dim dbs As DAO.Database
Dim rst As DAO.Recordset
Dim qdf As DAO.QueryDef
Dim Stg As String
'Dim I, J As Long
Dim NoDays As String
Dim FromTo As String
Stg = "SELECT Travels.*"
Stg = Stg & " FROM Travels"
Stg = Stg & " WHERE (((Travels.TravelID)=" & ID & "));"
Set dbs = CurrentDb
Set qdf = dbs.QueryDefs("Travels")
qdf.Parameters("ID") = ID
Set rst = qdf.OpenRecordset(dbOpenDynaset)
Set xlApp = CreateObject("Excel.Application")
xlApp.Visible = False
xlApp.Workbooks.Open "S:\General\LAAR\Database\Templates\AOT.XLS"
xlApp.Sheets(1).Cells(6, 5).Value = rst![Names]
xlApp.Sheets(1).Cells(7, 5).Value = rst![Purpose]
xlApp.Sheets(1).Cells(10, 5).Value = rst![Destination] & FromTo
xlApp.ActiveWorkbook.PrintOut
xlApp.ActiveWorkbook.Saved = False
xlApp.Quit
End Function
SF