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 Westi on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

GETFILE & IMPORT FROM don't like each other

Status
Not open for further replies.

Winston4

Programmer
Oct 30, 2006
2
US
I am trying to have the user select an Excel file (GETFILE) which my code then tries to do an IMPORT FROM to load the file into a new table. I get a "File does not exist" on the IMPORT FROM line. Any ideas?

Here are the two lines of code

File_import = GETFILE("Excel *.xls:XLS","","Import",0,"Select the file to import")

and

IMPORT FROM Filename_import TYPE XL8
(I have also tried several other lines ex:IMPORT FROM File_import DATABASE Database_name NAME Table_import TYPE XL8

Thanks for any help here.
 
What you try is to imort a file named Filename_import.XLS :)
You must use either a name expression ether macro (I oprefer first):
Code:
File_import = GETFILE("Excel *.xls:XLS","","Import",0,"Select the file to import")

IMPORT FROM (Filename_import) TYPE XL8

*** or
*** IMPORT FROM &Filename_import TYPE XL8
with macro expression you will have a problems if Filename_import has spaces in name.

Borislav Borissov
VFP9 SP1, SQL Server 2000/2005.
MVP VFP
 
You're also using two different variables for the same file. It seems to me you need this:

Code:
File_import = GETFILE("Excel *.xls:XLS","","Import",0,"Select the file to import")

IMPORT FROM ([b]File_import[/b]) TYPE XL8

Also, you should check to see if the user cancelled out of the dialogue:

Code:
File_import = GETFILE("Excel *.xls:XLS","","Import",0,"Select the file to import")
IF NOT EMPTY(File_import)
  IMPORT FROM (File_import) TYPE XL8
ENDIF

Mike

__________________________________
Mike Lewis (Edinburgh, Scotland)

My Visual FoxPro site: www.ml-consult.co.uk
 
Thanks guys. That is what I needed. Been long time since I coded in FoxPro and my syntax is quite rough.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top