How to stop appearing the "Overwrite with latest excel format" message

aman

Registered User.
Local time
Today, 00:08
Joined
Oct 16, 2008
Messages
1,251
Hi guys

Everytime when i run the following code then a message appears

"cc1.xls is a Microsoft Excel 5.0/95 workbook. Do you want to overwrite it with latest excel format,yes,no,cancel"

Code:
private sub save1()
strsql = "SELECT inputtable.[Date] as [Date],inputtable.Location as SourceLoc,inputtable.Department as SourceDept,inputtable.Barcode as Barcode,rebookinfo.date1 as RebookDate,rebookinfo.location as RebookLoc,rebookinfo.Department as RebookDept FROM inputtable,rebookinfo  WHERE inputtable.barcode=rebookinfo.barcodevalue order by barcode,rebookinfo.date1;"

If DCount("Name", "MSysobjects", "Name='qrytemp' and type=5") > 0 Then
DoCmd.DeleteObject acQuery, "qrytemp"
End If
Set qdf = CurrentDb.CreateQueryDef("qrytemp", strsql)

    Dim objXls As Excel.Application
    Dim objWrkBk As Excel.Workbook
    Dim xprtFile As String
    
     xprtFile = "C:\Documents and Settings\Amanpreet Kaur\Desktop\cc1.xls"
 
 DoCmd.OutputTo acOutputQuery, "qrytemp", acFormatXLS, xprtFile, False
    
    Set objXls = New Excel.Application
    objXls.Visible = False
    
    Set objWrkBk = objXls.Workbooks.Open(xprtFile)
    Set objWrkBk = objXls.Workbooks.Open(xprtFile)
    objWrkBk.Sheets("qrytemp").Select
    With objWrkBk.Sheets("qrytemp")
           .Application.Rows("1:1").Select
        .Application.Selection.Font.Bold = True
        '.Quit
        End With
 
 objWrkBk.Close SaveChanges:=True
        
   Set objWrkBk = Nothing
    objXls.Quit
    
    Set objXls = Nothing
Set qdf = Nothing
end sub

how can i avoid this message from appearing.

Cheers
 
Try turning the warnings off, but make sure you turn them back on again. Note, this won't work for all warning messages.

Application.DisplayAlerts = False
objWrkBk.Close SaveChanges:=True
Application.DisplayAlerts = True
 
Hi Kafrin

when i used those lines in the code then it started giving me Compile error: Method or data member not found at application.displayalerts line.

Thanks
Aman
 
Oops, sorry, should be:

objxls.DisplayAlerts = False
 
Hi Kafrin

Thanks a lot for your help.
It worked fine... :)

cheers
 

Users who are viewing this thread

Back
Top Bottom