Click a form button to reformat a spreadsheet

hardrock

Registered User.
Local time
Today, 18:00
Joined
Apr 5, 2007
Messages
166
Hi all,

I'm using the below code on a button click on my form. The code works by opening an existing spreadsheet and formats it. How do i get rid of the nagging prompt "Do you want to save the changes" when the the code executes? Thanks

' Open up the spreadsheet
Set xlapp = CreateObject("Excel.Application")
xlapp.Application.Visible = False
xlapp.workbooks.Open (ExportDir & ExportFile)

Set xlwkb = xlapp.Application.ActiveWorkbook
' Set overall font to Arial, 8pt
xlapp.Cells.Select
xlapp.Selection.Font.Name = "Arial"
xlapp.Selection.Font.Size = "8"

' Now put row headings to bold
xlapp.Application.Rows("1:1").Select
With xlapp.Application.Selection.Font
.Bold = True
End With

' Now autofit columns
xlapp.Cells.Select
xlapp.Selection.columns.AutoFit
xlapp.Application.Rows("1:1").Select
DoCmd.SetWarnings False

' Save and close the spreadsheets
xlapp.ActiveWorkbook.Save
xlapp.ActiveWorkbook.Close
 
Assuming that this is in Access, wrap your code with

DoCmd.SetWarnings False
'Your code
DoCmd.SetWarnings True
 
Already tried that mate.... problem is it works ok with Excel2003, the problem only occurs with closing an Excel2007 file down?
 

Users who are viewing this thread

Back
Top Bottom