Save as method generates 1004 error

L

Lp12

Hi All,
Im using Vista/Excel 2007 on domain.
I wrote a VBA code that save a xls file to csv. When I get to the line:
ActiveWorkbook.SaveAs Filename:=fname, FileFormat:=6, CreateBackup:=False it
generate the 1004 error.
I've tried running the code in a local XP (not domain) and it worked perfect.
Any suggestions?
Thanks a lot in advance.

Here is the entire code:

Sub CreateCSV()
On Error GoTo ErrorHandler
fname = "C:/One/Two"
Application.ScreenUpdating = False
ADPDir = Dir("C:\One\", vbDirectory)
If ADPDir <> "." Then
MkDir "C:\One"
If Len(Dir("C:\One\Two", vbDirectory)) = 0 Then
MkDir "C:\One\Two"
End If
End If
wbname = ActiveWorkbook.Name
Windows(wbname).Activate
shname = ActiveSheet.Name
Sheets(shname).Select
Range("A2:AC2").Select
Selection.Copy
Workbooks.Add
Range("A1").Select
ActiveSheet.Paste
Application.DisplayAlerts = False
Sheets("Sheet2").Delete
Sheets("Sheet3").Delete
ActiveWorkbook.SaveAs Filename:=fname, FileFormat:=6, CreateBackup:=False
 

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