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?
I wear a lot of hats...

"The solutions and answers provided on Experts Exchange have been extremely helpful to me over the last few years. I wear a lot of hats - Developer, Database Administrator, Help Desk, etc., so I know a lot of things but not a lot about one thing. Experts Exchange gives me answers from people who do know a lot about one thing, in a easy to use platform." -Todd S.

jrbbldrCommented:
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), _
        TrailingMinusNumbers:=True

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
0

Experts Exchange Solution brought to you by

Your issues matter to us.

Facing a tech roadblock? Get the help and guidance you need from experienced professionals who care. Ask your question anytime, anywhere, with no hassle.

Start your 7-day free trial
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.

broomee9
Experts-Exchange Cleanup Volunteer
0
It's more than this solution.Get answers and train to solve all your tech problems - anytime, anywhere.Try it for free Edge Out The Competitionfor your dream job with proven skills and certifications.Get started today Stand Outas the employee with proven skills.Start learning today for free Move Your Career Forwardwith certification training in the latest technologies.Start your trial today
FoxPro

From novice to tech pro — start learning today.