Trying to load a .txt file into a cell in Excel using Visual Foxpro

using VFP9, can't get a file to load into a spreadsheet cell.  using loExcel.loSheet1.oleobjects.add.filename()  property.   Don't know if I've got the syntax wrong or if VFP just won't work anymore with EXCEL.
Mark WhitfieldAsked:
Who is Participating?
One thing I always do to determine what Excel Automation code my VFP9 application needs to run is to do the same task in Excel totally without any VFP involvement.   And while I do it, I record the action as a Macro so that I can examine the resultant Macro VBA code and see what VFP needs to do.

In this instance I created 2 'text' files.  One is a .TXT file and the other is a .CSV file.
I then went into Excel (without VFP at all) and recorded Macros for Opening each file.

For the .TXT file, Excel 'asked' me to better define how to open the file and the resultant Macro VBA code looks like the following:
Workbooks.OpenText Filename:="C:\Temp\temp.txt", Origin:=437, StartRow:=1 _
        , DataType:=xlDelimited, TextQualifier:=xlDoubleQuote, _
        ConsecutiveDelimiter:=False, Tab:=True, Semicolon:=False, Comma:=False _
        , Space:=False, Other:=False, FieldInfo:=Array(1, 1), _

Open in new window

For the .CSV file, Excel was much more 'knowledgeable' as to what needed to be done.  
As such the resultant Macro VBA code was much more simple and looked like the following:
Workbooks.Open Filename:="C:\Temp\Temp.csv", Origin:=xlWindows

Open in new window

Now both of these were with Excel 2007.  You don't tell us what version of Excel you are using.  
Nor do you tell us what type of 'text' file you are trying to open.

Regardless, the Macro VBA code should give you an idea what your VFP Excel Automation code needs to look like.

NOTE:   As you are beginning your VFP Excel Automation development you should probably set your  loExcel.Visible = .T.   so that you can watch as each Automation line executes when single stepping through your VFP Automation code in your VFP Trace Window.

Good Luck
TracyVBA DeveloperCommented:
No comment has been added to this question in more than 21 days, so it is now classified as abandoned.

I have recommended this question be closed as follows:

Accept: jrbbldr (https:#a42463893)

If you feel this question should be closed differently, post an objection and the moderators will review all objections and close it as they feel fit. If no one objects, this question will be closed automatically the way described above.

Experts-Exchange Cleanup Volunteer
All Courses

From novice to tech pro — start learning today.