PDA

View Full Version : code does work at home but not at work ><



Eville
03-09-2009, 03:50 AM
Hi all,

The code below selects a range and copy it to a new file in csv format without the annoying boxes 'file already exists, are yoo sure you want to replace it?' popping up.
The code works perfect at home (microsoft excel 2002 (10.6840.6845) SP3) but at work (not sure what excel version is used there) it keeps popping up the box if i want to replace the file.
Also at home it makes a csv file (with the values actually separated with , ) but at work it just makes a copy with columns ><
I got this code because it does all actions on the background and updates automatically. Im using the csv-file as a database so i can import this into a new file again.
Is it because of the different versions in excel at home and at work that this doesnt work or is it something else?

Sub testexport()
'
' export Macro

Range("A3:E500").Select
Selection.Copy
Workbooks.Add
ActiveSheet.Paste
Application.DisplayAlerts = False
ActiveWorkbook.SaveAs FileName:= _
"C:\Documents and Settings\Work\CoilData.csv" _
, FileFormat:=xlCSV, CreateBackup:=False
Application.DisplayAlerts = False
ActiveWorkbook.Close
Application.DisplayAlerts = False
Range("A1").Select

End Sub


Thx in advance!
Ev

Bob Phillips
03-09-2009, 05:22 AM
It works fine for me with Excel 2003 and Excel 2007.