Importing Excel tables into Filemaker Pro 7

Hi, I have been using FMP 7 for a little under a year and Applescript a little longer, and I’m trying to do something that seems like it should be really simple in FMP 7, even without Applescript. I want to import an existing Excel table into an existing FMP database as a new table with all of the field names automatically created from the Excel table’s header row. I can get the Excel table to open in a NEW FMP database by simply drag and dropping the excel table onto FMP, but then I see no way of importing this table into the other existing FMP database without manually creating the table and all the field names to import into.

So… now I am trying to create an Applescript to grab the field names from the header row of the excel table, and create a new table in an open FMP database, with new fields being created for each column. My script is as follows:
Code:


tell application"FileMaker Pro"
	tell front document 
		tell last table
			create new field
		end tell
	end tell
end tell

And when I run this it gives me an error “FileMaker Pro got an error: Event not handled.” on the “create new field” line, even if I try it with “create new field with properties {name:“A new field”}”

So any ideas on how I can do this, with or without a script, easily? It should be simple and something that others have done in the past, no?

Thanks.

I don’t think you can actually access things that are in the Define Database options in FileMaker. So, you can’t create fields, tables, etc. At least, you couldn’t in previous versions of FileMaker. One problem I’m having is that AppleScript is not even properly recognizing commands to FileMaker 7 like “get name table 1 of document 1.” I think it is partially referencing older version of FileMaker I have installed. I’ve run into many frustrating oddities scripting FileMaker over the years.The best is when things randomly don’t work - they work once, they don’t work, they work if you change the syntax slightly, then stop working again after a while. Yeeech.

Good luck, but unless FM7 has somehow drastically improved AppleScript support (I haven’t seen that), then you cannot create fields/tables using AppleScript. You can’t even do that from within FileMaker’s own scripts.

Krioni is right. You can’t create tables or fields with Applescript. I have been frustrated by this in the past but now I don’t think it is a short-coming of the FileMaker dictionary. My guess is that it is a hornet’s nest FileMaker doesn’t want to disturb. If they made it possible to create tables and fields, how long do you think it would be before there was a post on Macscripter asking how to delete a table or field? What about creating relationships? I think they have to draw the line somewhere.

Krioni, have you tried using the whole application path in your tell blocks?  Instead of:
tell application "FileMaker Pro"
	-- your commands go here
end tell

Try:

tell application "StartupDisk:Applications:FileMaker Pro 7:FileMaker Pro.app:"
	-- your commands go here
end tell

This has solved a ton of headaches for me.