Save as DBF

  • Thread starter Thread starter bijan
  • Start date Start date
B

bijan

Hi
I'am using excel 2003, need a sample code for save as a non-active
sheet("test") to dBASE IV in C:\test\test.dbf and dont save as my workbook.
Thanks in advance
 
'create new workbook with only one sheet
'copy without using before or after put sheet in new workbook
Sheets("test").Copy
Set Newbk = ActiveWorkbook
Newbk.SaveAs _
Filename:="C:\test\test.dbf", _
FileFormat:=xlDBF4
Newbk.Close savechanges:=True
 
Hi,Joel
Thanks for code,How can change this code to ask me by a message box to set a
filename instead of test.dbf
Thanks
Bijan
 
fileSaveName = Application.GetSaveAsFilename( _
fileFilter:="DBF Files (*.dbf), *.dbf")
If fileSaveName <> False Then
MsgBox("Cannot open file - Exiting macro")
exit sub
End If


Sheets("test").Copy
Set Newbk = ActiveWorkbook
Newbk.SaveAs _
Filename:=fileSaveName, _
FileFormat:=xlDBF4
Newbk.Close savechanges:=True
 
Thanks Jole
It works grate but I had to remove this part:
If fileSaveName <> False Then
MsgBox("Cannot open file - Exiting macro")
exit sub
End If
beacuse, it just returns the text of msgbox
Bijan
 
Joel meant = False as below ... to exit the macro if no file is selected..

If fileSaveName = False Then
MsgBox ("Cannot open file - Exiting macro")
Exit Sub
End If

If this post helps click Yes
 
Back
Top