Click here to Skip to main content
15,886,806 members
Please Sign up or sign in to vote.
1.00/5 (1 vote)
See more:
I need a macro that will open a .DBF file to a tab in my worksheet. Is this possible? If so, can you show me the code needed and if not would you have any alternative suggestions? Thank you
Posted

Yes it is possible. There is an example here[^] - and several other examples can be found with the google search
Quote:
excel vba open dbf file
 
Share this answer
 
Sub ABC()
Dim r1 as Range, r as Range, bk as Workbook
set r1 = Activesheet.range(“A1″)
set bk = workbooks.open(“C:\Myfolder\Myfile.dbf”)
set r = bk.worksheets(1).Range(“A1″).currentRegion
r.copy r1
bk.close SaveChanges:=False
end sub

That is the way I have been doing it successfully in xl2003 and earlier for years. Support for Saving as DBF was dropped in xl2007 for sure but I believe it can still read a dbf file.
And more use: DBF Restore Toolbox fo restore your files simple,
http://itknowledgeexchange.techtarget.com/itanswers/how-do-i-open-a-dbf-file-to-a-tab-in-my-worksheet/[^]
 
Share this answer
 

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900