Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations strongm on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

SaveFile Excel as DBF file behind the scenes

Status
Not open for further replies.

badrion

Programmer
Jul 16, 2001
34
US
Any help would be great. I have an excel file that I would like to save as a DBF... but I don't want the user to see it happening.
 
You could use Application.ScreenUpdating=False so things happen in the background and set it back to True when done. You could record the macro and get the code for SaveAs. The only thing you might have to worry about is how you want things to be controlled; meaning I'm not familiar with .DBF but I guess it saves only the active sheet. If you're Saving As, you've "lost" the worksheet that the macro was running from unless it's a 'master' file and opens up another sheet and performs save as on it. There is a function SaveCopyAs but I've only used it once. I don't know if it will also save as a different type, it might just be .xls with a different name without affecting the current worksheet.

I'm sure someone else has a better explanation for the control flow.
 
I have tried so many different ways to do a SaveAs .dbf and nothing is working. I tried the savecopyas and saveas and excel.activeworkbooks.saveas...Ive even tried the xlbuiltindialog.saveas.

Any ideas from anyone would be great!
 
Would something like this work?

Aplication.ScreenUpdating=False
Windows("mbr.txt").Activate
ActiveWorkbook.SaveAs Filename:="C:\Scottr\mbr.dbf", FileFormat:=xlDBF4, _
CreateBackup:=False
ActiveWindow.Close
Application.ScreenUpdating=True

This scenerio could work if run from a master.xls document, for example. You could open a document, such as mbr.txt (then you wouldn't need the Activate statement) or you could copy your data to a new workbook and then SaveAs your .DBF.
I'm not familiar with DBF files so just tell me if I'm wasting your time.
 
I would think there is a simple line of code that would take one file and rename it. I've tried what you said, modified alittle and still no go..... Thanks for the ideas though.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top