Help!! Make message box go bye-bye

G

Guest

When I run the following code, I get message boxes that
pop up that ask if I want to save the files. Since I am
actually saving these files already, the message box seems
a little redundant. Is there anyway to write code to
automatically answer these as no or is there a way to keep
them from popping up at all?

Sub DataImport()

Dim App As Object
Set App = CreateObject("Excel.Application")
App.Visible = False
App.UserControl = False

Dim Book1 As Object
Set Book1 = App.Workbooks.Open("C:\Import
Data\exceldr.dat")
Book1.SaveAs ("C:\Import Data\exceldr.xls")
Book1.Close

Dim Book2 As Object
Set Book2 = App.Workbooks.Open("C:\Import
Data\excelwr.dat")
Book2.SaveAs ("C:\Import Data\excelwr.xls")
Book2.Close


Dim Book3 As Object
Set Book3 = App.Workbooks.Open("C:\Import
Data\safereq.dat")
Book3.SaveAs ("C:\Import Data\safereq.xls")
Book3.Close

Set Book1 = Nothing
Set Book2 = Nothing
Set Book2 = Nothing

App.Quit
Set App = Nothing
 
T

Tim Ferguson

Is there anyway to write code to
automatically answer these as no or is there a way to keep
them from popping up at all?

Are you sure it's a Save? message or an Overwrite? warning -- since you
have the target names hardwired I assume the old files are still there when
you do the copy. Try Killing the old file before doing the write.

I also appreciate that you are giving a truncated piece of code here
(thanks!) but if you really just want to copy the files you could of course
use FileCopy or even the FileSystemObject to do it with better control and
much faster. It might even pay to copy the files first and then open the
copies in Excel.

B wishes

Tim F
 
J

Jeff

These are .dat files that I am converting into .xls files
so I can import them into Access. Therefore, I am not
copying the files, but actually saving them in a format I
can use. Since the original files have a .dat extension,
when the SaveAs is performed the files are saved
differently so there is no overwrite warning. I get a
message box that says "Do you want to save the changes to
exceldr.xls'? I get this box for each SaveAs file. I
there a way to anser these boxes in the code itself so
they do not pop up?
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top