Richard said:
Hi Dirk
Actually it worked. I was waiting for it to open up to Excel. I
checked the mdb folder and there was all the files I transfered..hehe
Is there a way for it to open when I transfer? I need to save it as a
.db file.
You could use DoCmd.OutputTo (you'll find it in the help file) instead
of TransferSpreadsheet, and then use that method's "AutoStart" argument
to cause Excel to open the exported file. One drawback to this is that
OutputTo gives you no choice as to the specific Excel file-format used,
and I think it uses an older, more limited file format.
Another option is to export to the file using TransferSpreadsheet, and
then either use
Application.FollowHyperlink <path and name of exported .xls file>
to open it -- or call the ShellExecute API -- or else use automation to
create an Excel application object and tell that object to open the
spreadsheet file. If the whole purpose of opening the file in Excel is
to convert it to a .db (.dbf?) file, you would probably want to go the
route of automating Excel, so there would be no need for the user to
actually work with Excel manually at all.
On the other hand, if your whole purpose is to come up with this .db
file, I think you should be able to use TransferDatabase to do it in one
go, instead of TransferSpreadsheet followed by some manipulation of
Excel. What specific format are you targeting? This works for me:
DoCmd.TransferDatabase acExport, "dBase IV", _
"C:\Temp", acQuery, "qryTest", "qryTest.dbf"