Level Extreme platform
Subscription
Corporate profile
Products & Services
Support
Legal
Français
Running Microsoft Excel from VFP
Message
From
28/12/1997 01:09:13
 
 
To
28/12/1997 00:05:29
General information
Forum:
Visual FoxPro
Category:
Other
Miscellaneous
Thread ID:
00067923
Message ID:
00068124
Views:
49
>>>>>>In my reporting section, I'm giving a option of transferring reports to excel..
>>>>>>
>>>>>>Here, I am simply redirecting the output to a txt file and then starting excel with the txt file name as the command line parameter...
>>>>>>
>>>>>>I have questions for the same :-
>>>>>>
>>>>>>1. Is there any way I can retrieve the Path of Microsoft Excel, so I can provide it in the run parameter..
>>>>>>as on every machine it is not sure that its installed in same dir..
>>>>>>
>>>>>>2. Is there any better way to do this whole thing...
>>>>>
>>>>>Look in the samples provided by MS, they are very help in this regard.. You will want to use OLE to try and strta up a copy of Excel, and if the BUILDOBJ() fails, they have NO Excel loaded..
>>>>>
>>>>>Thanx!
>>>>>
>>>>>Tony Miller
>>>>>Vancouver, Wa
>>>>
>>>>Pls note that I'm Using VFP 3.0b, Can u pls tell me where is the example given for Excel ??
>>>
>>>Under samples, I do believe there is an example of OLE driven applications.. However, doing this under 3.0 is not as great as 5.0...
>>>
>>>
>>>Thanx!
>>>
>>>Tony Miller
>>>Vancouver, Wa
>>
>>Actually main problem is few of our machines are still running win 3.11, so have to stick with vfp 3.0b..
>>
>>Can u pls give me any tip/idea for vfp 3
>
>If you do the following in the command window of VFP, you will be executing the Solutions demo included with VFP.. In there are code samples for working with OLE objects and VFP..
>
>SET DEFAULT TO c:\vfp\samples\solution
>DO solution.app
>
>
>In there is code to handle the situation you have brought up..
>
>Thanx!
>
>Tony Miller
>Vancouver, Wa

The option of giving the user what he wants in Excel works great for Accountants - they feel at home in Excel - so why not make them happy - they might even pay my next invoice quicker.
Here is a snippet of code from an app that works, it is in the Click() method of a Commandbutton.
oleApp = CREATEOBJECT("Excel.Application") &&Start Excel.
OleApp.Visible=.T. &&Display Excel. They see the data arriving on a slow machine.
OleApp.Workbooks.Add &&Create a workbook.
*OleApp.Columns.AutoFit
OleApp.Cells(2,2).ColumnWidth = 20
OleApp.Cells(1,1).ColumnWidth = 20
OleApp.Cells(2,2).NumberFormat = "d-mmm-yy"
OleApp.Cells(3,2).NumberFormat = "d-mmm-yy"
OleApp.Cells(4,2).NumberFormat = "$#,##0.00"
OleApp.Cells(6,2).NumberFormat = "$#,##0.00"
OleApp.Cells(7,2).NumberFormat = "$#,##0.00"
OleApp.Cells(8,2).NumberFormat = "$#,##0.00"
OleApp.Cells(9,2).NumberFormat = "$#,##0.00"
OleApp.Cells(10,2).NumberFormat = "$#,##0.00"
OleApp.Cells(11,2).NumberFormat = "$#,##0.00"
OleApp.Cells(12,2).NumberFormat = "$#,##0.00"
OleApp.Cells(13,2).NumberFormat = "$#,##0.00"
OleApp.Cells(1,1).Value= setup.orgname
OleApp.Cells(2,1).value = "FROM"
OleApp.Cells(2,2).value = ThisForm.Start_date.value
OleApp.Cells(3,1).value = "TO"
OleApp.Cells(3,2).value = ThisForm.End_date.value
OleApp.Cells(4,1).value = "Liability"
OleApp.Cells(5,1).value = "Levy Kgs"
OleApp.Cells(4,2).Value = ThisForm.Total_liability.value
OleApp.Cells(5,2).Value = ThisForm.levy_kgs.value
etc.
this snip shows how to do a variety of things in the Excel . I found that it was easy to get what Excel needed by recording a macro in Excel, then interpreting that info in VFP.
This way they get the data into a familiar environment and can do as they wish with it. Keeps em happy And they think it is magic, the way the data they need just appears.

You can do this with Word and other "Ole.Applications" to do those fancy letters without having to reinvent the wheel in VFP,
Previous
Reply
Map
View

Click here to load this message in the networking platform